You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Don't flush synchronous work if we're in the middle of a ViewTransition async sequence (#32760)
Starting a View Transition is an async sequence. Since React can get a
sync update in the middle of sequence we sometimes interrupt that
sequence.
Currently, we don't actually cancel the View Transition so it can just
run as a partial. This ensures that we fully skip it when that happens,
as well as warn.
However, it's very easy to trigger this with just a setState in
useLayoutEffect right now. Therefore if we're inside the preparing
sequence of a startViewTransition, this delays work that would've
normally flushed in a microtask. ~Maybe we want to do the same for
Default work already scheduled through a scheduler Task.~ Edit: This was
already done.
`flushSync` currently will still lead to an interrupted View Transition
(with a warning). There's a tradeoff here whether we want to try our
best to preserve the guarantees of `flushSync` or favor the animation.
It's already possible to suspend at the root with `flushSync` which
means it's not always 100% guaranteed to commit anyway. We could treat
it as suspended. But let's see how much this is a problem in practice.
DiffTrain build for [a5297ec](a5297ec)
"A flushSync update cancelled a View Transition because it was called while the View Transition was still preparing. To preserve the synchronous semantics, React had to skip the View Transition. If you can, try to avoid flushSync() in a scenario that's likely to interfere."
14845
+
)),
14846
+
(pendingViewTransition = null));
14833
14847
flushMutationEffects();
14834
14848
flushLayoutEffects();
14835
14849
flushSpawnedWork();
@@ -17826,6 +17840,7 @@ __DEV__ &&
17826
17840
didWarnAboutUndefinedSnapshotBeforeUpdate = null;
17827
17841
didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
"A flushSync update cancelled a View Transition because it was called while the View Transition was still preparing. To preserve the synchronous semantics, React had to skip the View Transition. If you can, try to avoid flushSync() in a scenario that's likely to interfere."
14659
+
)),
14660
+
(pendingViewTransition = null));
14647
14661
flushMutationEffects();
14648
14662
flushLayoutEffects();
14649
14663
flushSpawnedWork();
@@ -17598,6 +17612,7 @@ __DEV__ &&
17598
17612
didWarnAboutUndefinedSnapshotBeforeUpdate = null;
17599
17613
didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
0 commit comments