From a8c497e9e548541b4ff82d67cc26b6677fd6198d Mon Sep 17 00:00:00 2001 From: Josh Story Date: Mon, 17 Oct 2022 15:21:06 -0700 Subject: [PATCH] move resource acquisition to mutation phase (#25500) --- .../src/ReactFiberCommitWork.new.js | 26 +++++++++---------- .../src/ReactFiberCommitWork.old.js | 26 +++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.new.js b/packages/react-reconciler/src/ReactFiberCommitWork.new.js index 343cc152d735c..237b036be7efb 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.new.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.new.js @@ -1086,19 +1086,6 @@ function commitLayoutEffectOnFiber( committedLanes, ); - if (flags & Update) { - const newResource = finishedWork.memoizedState; - if (current !== null) { - const currentResource = current.memoizedState; - if (currentResource !== newResource) { - releaseResource(currentResource); - } - } - finishedWork.stateNode = newResource - ? acquireResource(newResource) - : null; - } - if (flags & Ref) { safelyAttachRef(finishedWork, finishedWork.return); } @@ -2614,6 +2601,19 @@ function commitMutationEffectsOnFiber( safelyDetachRef(current, current.return); } } + + if (flags & Update) { + const newResource = finishedWork.memoizedState; + if (current !== null) { + const currentResource = current.memoizedState; + if (currentResource !== newResource) { + releaseResource(currentResource); + } + } + finishedWork.stateNode = newResource + ? acquireResource(newResource) + : null; + } return; } } diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.old.js b/packages/react-reconciler/src/ReactFiberCommitWork.old.js index 0dac9e775a7fb..e8a0abca76b29 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.old.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.old.js @@ -1086,19 +1086,6 @@ function commitLayoutEffectOnFiber( committedLanes, ); - if (flags & Update) { - const newResource = finishedWork.memoizedState; - if (current !== null) { - const currentResource = current.memoizedState; - if (currentResource !== newResource) { - releaseResource(currentResource); - } - } - finishedWork.stateNode = newResource - ? acquireResource(newResource) - : null; - } - if (flags & Ref) { safelyAttachRef(finishedWork, finishedWork.return); } @@ -2614,6 +2601,19 @@ function commitMutationEffectsOnFiber( safelyDetachRef(current, current.return); } } + + if (flags & Update) { + const newResource = finishedWork.memoizedState; + if (current !== null) { + const currentResource = current.memoizedState; + if (currentResource !== newResource) { + releaseResource(currentResource); + } + } + finishedWork.stateNode = newResource + ? acquireResource(newResource) + : null; + } return; } }