Back to results for “Performance”
React › Strict Mode & Concurrent Features

What is automatic batching in React, and how does it improve performance?

Intermediate

Answer

Automatic batching means React groups multiple state updates that happen close together into a single re render, instead of re rendering separately for each one. This reduces unnecessary rendering work, and modern React applies this batching consistently, even inside things like promises and event handlers where it previously did not happen automatically.
function handleClick() {
  setCount((c) => c + 1);
  setFlag((f) => !f);
  // React batches both of these together into a single re render
}
Real-world example A form that updates three separate pieces of state inside one click handler only causes a single re render instead of three separate ones, thanks to React's automatic batching combining all three updates together.

Common follow-ups: Did earlier versions of React batch updates inside things like setTimeout callbacks the same way?;How would you force an update to happen immediately instead of being batched, if truly needed?