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.