Q38: What is ReactDOM.flushSync and when should it be used?
ReactDOM.flushSync() forces React to flush any pending state updates inside its callback synchronously, updating the real DOM immediately before the current JavaScript block completes.
Key Takeaways
Forces immediate synchronous DOM updates.
Use sparingly as it disrupts React performance batching optimizations.
Knowledge Check
What is the primary effect of wrapping a state setter inside ReactDOM.flushSync()?