@samitouri / QOS-React-2 / commits / b44e4b13a9

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.

Andrew Clark committed Nov 13, 2020 at 12:45 UTC b44e4b13a99901281ee02f66930fbc24181993d2
1 file changed +8 -2
packages/react-reconciler/src/ReactFiberCompleteWork.new.js
+8 -2
@@ -178,12 +178,18 @@ function hadNoMutationsEffects(current: null | Fiber, completedWork: Fiber) {
178 return true;
179 }
180
181 + if ((completedWork.flags & Deletion) !== NoFlags) {
182 + return false;
183 + }
184 +
185 + // TODO: If we move the `hadNoMutationsEffects` call after `bubbleProperties`
186 + // then we only have to check the `completedWork.subtreeFlags`.
187 let child = completedWork.child;
188 while (child !== null) {
183 - if ((child.flags & MutationMask) !== NoFlags) {
189 + if ((child.flags & (MutationMask | Deletion)) !== NoFlags) {
190 return false;
191 }
186 - if ((child.subtreeFlags & MutationMask) !== NoFlags) {
192 + if ((child.subtreeFlags & (MutationMask | Deletion)) !== NoFlags) {
193 return false;
194 }
195 child = child.sibling;