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.
This commit is contained in:
Andrew Clark
2020-11-13 10:45:46 -08:00
committed by GitHub
parent 3ebf05183d
commit b44e4b13a9
@@ -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;