Skip to content

Commit

Permalink
Check for deletions in hadNoMutationsEffects (#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 Nov 13, 2020
1 parent 3ebf051 commit b44e4b1
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 b44e4b1

Please sign in to comment.