diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.new.js b/packages/react-reconciler/src/ReactFiberBeginWork.new.js index 3df345b6380bd..430a46029ec57 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.new.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.new.js @@ -748,14 +748,16 @@ function updateOffscreenComponent( subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes); + let prevCachePool = null; if (enableCache) { // If the render that spawned this one accessed the cache pool, resume // using the same cache. Unless the parent changed, since that means // there was a refresh. - const prevCachePool = prevState.cachePool; - pushTransition(workInProgress, prevCachePool, null); + prevCachePool = prevState.cachePool; } + pushTransition(workInProgress, prevCachePool, null); + // Since we're not hidden anymore, reset the state workInProgress.memoizedState = null; } else { diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.old.js b/packages/react-reconciler/src/ReactFiberBeginWork.old.js index 66324c8dc3336..05e769018c786 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.old.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.old.js @@ -748,14 +748,16 @@ function updateOffscreenComponent( subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes); + let prevCachePool = null; if (enableCache) { // If the render that spawned this one accessed the cache pool, resume // using the same cache. Unless the parent changed, since that means // there was a refresh. - const prevCachePool = prevState.cachePool; - pushTransition(workInProgress, prevCachePool, null); + prevCachePool = prevState.cachePool; } + pushTransition(workInProgress, prevCachePool, null); + // Since we're not hidden anymore, reset the state workInProgress.memoizedState = null; } else {