React batches state updates that occur in event handlers and lifecycle methods. Thus, if you update state multiple times in a <div onClick /> handler, React will wait for event handling to finish before re-rendering.
To be clear, this only works in React-controlled synthetic event handlers and lifecycle methods. State updates are not batched in AJAX and setTimeout event handlers, for example.
UPDATE
With the release of React v18.0, state updates within non-React events (promises, setTimeout etc.) are also batched by default.
Ref – https://reactjs.org/blog/2022/03/29/react-v18.html#new-feature-automatic-batching