automatic batching
React groups several state updates made in the same event or task into a single re-render.
In more detail
Since React 18 this happens everywhere, including inside promises and timeouts, not just in event handlers. It avoids wasted renders and prevents the screen from showing half-updated state. DOM changes are batched the same way and applied together in the commit phase.
Related terms
- useState — The React hook that adds a state variable to a component and returns the current value with a function to change it.
- state snapshot — The idea that during one render every state value is fixed, so code in that render always sees the same value even after calling a setter.
- commit phase — The part of an update where React applies the calculated changes to the real DOM, all at once and without interruption.
Taught in
- State with useState: Immutability And Asynchronous Batching — React 19 & Modern Component Architecture
- Virtual DOM vs Real DOM: The Reconciliation Cost Model — React 19 & Modern Component Architecture