React · Middle · Question 25 of 75

What is automatic batching in React 18+?

Explanation

Before React 18, updates were batched only in React event handlers. Now setA(); setB(); inside setTimeout, fetch().then() or native handlers produce one render. If you need to apply an update synchronously (e.g. before measuring the DOM), use flushSync.

Further reading

Problem with a question

React · Middle · question 25

Test yourself

Take the React · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz