From 55a21ef7e78a4e35302cbc7ffb19934a23cc6957 Mon Sep 17 00:00:00 2001 From: Luna Ruan Date: Mon, 11 Apr 2022 16:54:25 -0500 Subject: [PATCH] fix pushTransition for transition tracing (#24338) We forgot to move pushTransition out from the enableCache flag in #24321 in a place that both transition tracing and cache need to push transitions. Move it out from behind the enableCache to prepare for the next PRs. --- packages/react-reconciler/src/ReactFiberBeginWork.new.js | 6 ++++-- packages/react-reconciler/src/ReactFiberBeginWork.old.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) 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 {