What is the use of batch()? #1899
Answered
by
markerikson
binarybehemoth
asked this question in
Q&A
-
I am trying to explain the React-Redux batch() function on my website. In order to do so, I need a counterexample without using batch() so that the reader can see the difference. However, as you can see here on CodeSandbox, I couldn't get the counterexample to work, as batching occurred even without calling batch(), ie. the number is incremented by two instead of one at a time. |
Beta Was this translation helpful? Give feedback.
Answered by
markerikson
Apr 14, 2022
Replies: 1 comment 4 replies
-
You're using React 18, which now always does batching automatically. But, React 17 and earlier did not do that: |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
binarybehemoth
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're using React 18, which now always does batching automatically. But, React 17 and earlier did not do that:
reactwg/react-18#21