diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.new.js b/packages/react-reconciler/src/ReactFiberCommitWork.new.js index 0d2cb1da6b4d7..a879f457aaf0f 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.new.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.new.js @@ -1089,19 +1089,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); } @@ -2617,6 +2604,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 0751cd7d2e6cb..0b772d65077fe 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.old.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.old.js @@ -1089,19 +1089,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); } @@ -2617,6 +2604,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; } }