Skip to content

Commit

Permalink
Check for deletions in hadNoMutationsEffects (facebook#20252)
Browse files Browse the repository at this point in the history
When detecting if a host tree was changed, we must check for deletions
in addition to mounts and updates.
  • Loading branch information
acdlite authored and koto committed Jun 15, 2021
1 parent 3bd5382 commit 79d1c16
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/react-reconciler/src/ReactFiberCompleteWork.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 79d1c16

Please sign in to comment.