Skip to content

Commit fcd720d

Browse files
authored
[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.
1 parent 522f473 commit fcd720d

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

packages/react-reconciler/src/ReactFiberBeginWork.new.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,17 @@ function updateOffscreenComponent(
779779
prevCachePool = prevState.cachePool;
780780
}
781781

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);
783793

784794
// Since we're not hidden anymore, reset the state
785795
workInProgress.memoizedState = null;

packages/react-reconciler/src/ReactFiberBeginWork.old.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,17 @@ function updateOffscreenComponent(
779779
prevCachePool = prevState.cachePool;
780780
}
781781

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);
783793

784794
// Since we're not hidden anymore, reset the state
785795
workInProgress.memoizedState = null;

0 commit comments

Comments
 (0)