Opt-out of Automatic Batching with ReactDOM.flushSync

InstructorMichael Chan

Share this video with your friends

Send Tweet

In React 18, useState update calls are batched for improved performance. A new API — ReactDOM.flushSync — lets us selectively escape batching. This option is useful when reading the DOM after state changes. Use ReactDOM.flushSync to exempt specific state updates from batching.