diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.new.js b/packages/react-reconciler/src/ReactFiberBeginWork.new.js index 0688ae8a04f6e..c8c1f3cbb05a9 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.new.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.new.js @@ -779,7 +779,17 @@ function updateOffscreenComponent( prevCachePool = prevState.cachePool; } - pushTransition(workInProgress, prevCachePool, null); + let transitions = null; + if ( + workInProgress.memoizedState !== null && + workInProgress.memoizedState.transitions !== null + ) { + // We have now gone from hidden to visible, so any transitions should + // be added to the stack to get added to any Offscreen/suspense children + transitions = workInProgress.memoizedState.transitions; + } + + pushTransition(workInProgress, prevCachePool, transitions); // Since we're not hidden anymore, reset the state workInProgress.memoizedState = null; diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.old.js b/packages/react-reconciler/src/ReactFiberBeginWork.old.js index 74595fda43425..8f98c76b3b1aa 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.old.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.old.js @@ -779,7 +779,17 @@ function updateOffscreenComponent( prevCachePool = prevState.cachePool; } - pushTransition(workInProgress, prevCachePool, null); + let transitions = null; + if ( + workInProgress.memoizedState !== null && + workInProgress.memoizedState.transitions !== null + ) { + // We have now gone from hidden to visible, so any transitions should + // be added to the stack to get added to any Offscreen/suspense children + transitions = workInProgress.memoizedState.transitions; + } + + pushTransition(workInProgress, prevCachePool, transitions); // Since we're not hidden anymore, reset the state workInProgress.memoizedState = null;