What is batching, and did it change in React 18?
Quick answer
React groups multiple state updates in the same event into one re-render. React 18 made batching automatic everywhere, including promises, timeouts, and native handlers.
In detail
Before React 18, updates were only batched inside React event handlers; updates inside setTimeout, promises, or native events caused separate re-renders. React 18's automatic batching groups all of them, reducing renders with no code change. You can opt out for a specific update with flushSync if you truly need a synchronous DOM update.
setTimeout(() => {
setCount(c => c + 1);
setFlag(f => !f);
// React 18: a single re-render (was two before)
}, 0);Why interviewers ask this: A current-knowledge check on React 18 behaviour.
This is 1 of 118+ questions in the React Interview Kit
Get every question with detailed answers, follow-ups and real code — plus coding challenges and a last-minute revision sheet. One-time payment, instant access.
⚡ Get the React Interview Kit → ₹399