React · Senior · Question 30 of 75
When is flushSync justified?
- ✓Correct answer: When the DOM must update synchronously before the next line of code
- 2When you need to speed up any render by disabling batching
- 3When you need to send state to the server before a page transition
Explanation
Example: you added a message and want to scroll to it immediately - without flushSync, the new DOM node doesn't exist yet. It's also needed when integrating with third-party code like onbeforeprint. It's an expensive operation that breaks batching and concurrent optimizations - use it sparingly.