React·100 questions

How does batch updates work in React?

Answer
React can combine multiple setState calls into one render.
This reduces re-renders.
In React 18, batching works even in async contexts.
Don't rely on the order of setters without functional form.
For synchronous reads, use useEffect after render.
Was this answer helpful?

More questions in this topic

Related questions from other topics