@samitouri / QOS-React-2 / commits / fcd720d363

[Transition Tracing] Push Transition When Offscreen Becomes Visible (#24718)

This PR pushes all of a suspense boundary's transitions onto the transition stack when it goes from hidden to visible so we can pass it to any child suspense boundaries or tracing markers.

Luna Ruan committed Jun 15, 2022 at 11:51 UTC fcd720d3631a23a9e273db60bf2d35ff5f7dc406
2 files changed +22 -2
packages/react-reconciler/src/ReactFiberBeginWork.new.js
+11 -1
@@ -779,7 +779,17 @@ function updateOffscreenComponent(
779 prevCachePool = prevState.cachePool;
780 }
781
782 - pushTransition(workInProgress, prevCachePool, null);
782 + let transitions = null;
783 + if (
784 + workInProgress.memoizedState !== null &&
785 + workInProgress.memoizedState.transitions !== null
786 + ) {
787 + // We have now gone from hidden to visible, so any transitions should
788 + // be added to the stack to get added to any Offscreen/suspense children
789 + transitions = workInProgress.memoizedState.transitions;
790 + }
791 +
792 + pushTransition(workInProgress, prevCachePool, transitions);
793
794 // Since we're not hidden anymore, reset the state
795 workInProgress.memoizedState = null;
packages/react-reconciler/src/ReactFiberBeginWork.old.js
+11 -1
@@ -779,7 +779,17 @@ function updateOffscreenComponent(
779 prevCachePool = prevState.cachePool;
780 }
781
782 - pushTransition(workInProgress, prevCachePool, null);
782 + let transitions = null;
783 + if (
784 + workInProgress.memoizedState !== null &&
785 + workInProgress.memoizedState.transitions !== null
786 + ) {
787 + // We have now gone from hidden to visible, so any transitions should
788 + // be added to the stack to get added to any Offscreen/suspense children
789 + transitions = workInProgress.memoizedState.transitions;
790 + }
791 +
792 + pushTransition(workInProgress, prevCachePool, transitions);
793
794 // Since we're not hidden anymore, reset the state
795 workInProgress.memoizedState = null;