From b44e4b13a99901281ee02f66930fbc24181993d2 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Fri, 13 Nov 2020 12:45:46 -0600 Subject: [PATCH] Check for deletions in `hadNoMutationsEffects` (#20252) When detecting if a host tree was changed, we must check for deletions in addition to mounts and updates. --- .../react-reconciler/src/ReactFiberCompleteWork.new.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberCompleteWork.new.js b/packages/react-reconciler/src/ReactFiberCompleteWork.new.js index 1b353a097268d..da98e0c4de34f 100644 --- a/packages/react-reconciler/src/ReactFiberCompleteWork.new.js +++ b/packages/react-reconciler/src/ReactFiberCompleteWork.new.js @@ -178,12 +178,18 @@ function hadNoMutationsEffects(current: null | Fiber, completedWork: Fiber) { return true; } + if ((completedWork.flags & Deletion) !== NoFlags) { + return false; + } + + // TODO: If we move the `hadNoMutationsEffects` call after `bubbleProperties` + // then we only have to check the `completedWork.subtreeFlags`. let child = completedWork.child; while (child !== null) { - if ((child.flags & MutationMask) !== NoFlags) { + if ((child.flags & (MutationMask | Deletion)) !== NoFlags) { return false; } - if ((child.subtreeFlags & MutationMask) !== NoFlags) { + if ((child.subtreeFlags & (MutationMask | Deletion)) !== NoFlags) { return false; } child = child.sibling;