What is state batching in React?
Model answer
React groups several state updates that happen in the same event or tick into a single re-render for better performance. In React 18 and later this automatic batching also applies inside promises, timeouts and native event handlers.
You rarely need to do anything. In the rare case where you must read the DOM right after an update, flushSync forces a synchronous render, but use it sparingly.
Learn this topic
React useState Explained: Make Your Page React to Change in the course React.js Full Course: Beginner to Advanced.
Sign in to add your own answer.