Concurrent Rendering State Consistency Limits with Mixed Urgency Updates
26K reputation · 21 Nov 2020, 03:27 UTC
React's concurrent rendering model allows the scheduler to interrupt low-priority updates to handle urgent interactions, ensuring the main thread remains responsive. This is primarily managed through the useTransition hook and the startTransition API.
A challenge arises when an application mixes urgent state updates with non-urgent transitions that depend on the same shared state. Because concurrent rendering can pause and resume updates, there is a risk of inconsistency if the state evolves between the start of a transition and its eventual commit.
When managing complex state trees, it is unclear how React ensures that a deferred update does not overwrite a more recent urgent update that occurred while the transition was pending.
- How does React prevent state "tearing" when an urgent update modifies a value currently being processed by a concurrent transition?
- What are the specific constraints on state mutations to ensure consistency across different priority lanes?