From 30f1466687b742d359037b0481e5d31fd1b199a0 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 1 Nov 2022 15:01:55 +0000 Subject: [PATCH] Add comment and make the condition more obvious --- packages/react-reconciler/src/ReactFiberCommitWork.new.js | 3 ++- packages/react-reconciler/src/ReactFiberCommitWork.old.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.new.js b/packages/react-reconciler/src/ReactFiberCommitWork.new.js index 9fd3ec8674fc2..f3fa8fbb21552 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.new.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.new.js @@ -2880,7 +2880,8 @@ function commitMutationEffectsOnFiber( } if (isHidden) { - if (current !== null && current.memoizedState === null) { + // Check if this is an update, and the tree was previously visible. + if (current !== null && !wasHidden) { if ((offscreenBoundary.mode & ConcurrentMode) !== NoMode) { // Disappear the layout effects of all the children recursivelyTraverseDisappearLayoutEffects(offscreenBoundary); diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.old.js b/packages/react-reconciler/src/ReactFiberCommitWork.old.js index c8dfe4b3b63b9..ea1ff57f3d8db 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.old.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.old.js @@ -2880,7 +2880,8 @@ function commitMutationEffectsOnFiber( } if (isHidden) { - if (current !== null && current.memoizedState === null) { + // Check if this is an update, and the tree was previously visible. + if (current !== null && !wasHidden) { if ((offscreenBoundary.mode & ConcurrentMode) !== NoMode) { // Disappear the layout effects of all the children recursivelyTraverseDisappearLayoutEffects(offscreenBoundary);