From 58064fcb16e3d41a89225acade08d2075ff2d39b Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Mon, 7 Dec 2020 15:07:28 -0600 Subject: [PATCH] Add Placement bit without removing others (#20398) When scheduling a Placement effect, we should add the Placement bit without resetting the others. In the old fork, there are no flags to reset, anyway, since by the time we reach the child reconciler, the flags will have already been reset. However, in the effects refactor, "static" flags are not reset, so this can actually manifest as a bug. See #20285 for a regression test. --- packages/react-reconciler/src/ReactChildFiber.new.js | 6 +++--- packages/react-reconciler/src/ReactChildFiber.old.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/react-reconciler/src/ReactChildFiber.new.js b/packages/react-reconciler/src/ReactChildFiber.new.js index 52bd632721184..a92f6a6790d57 100644 --- a/packages/react-reconciler/src/ReactChildFiber.new.js +++ b/packages/react-reconciler/src/ReactChildFiber.new.js @@ -342,7 +342,7 @@ function ChildReconciler(shouldTrackSideEffects) { const oldIndex = current.index; if (oldIndex < lastPlacedIndex) { // This is a move. - newFiber.flags = Placement; + newFiber.flags |= Placement; return lastPlacedIndex; } else { // This item can stay in place. @@ -350,7 +350,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } else { // This is an insertion. - newFiber.flags = Placement; + newFiber.flags |= Placement; return lastPlacedIndex; } } @@ -359,7 +359,7 @@ function ChildReconciler(shouldTrackSideEffects) { // This is simpler for the single child case. We only need to do a // placement for inserting new children. if (shouldTrackSideEffects && newFiber.alternate === null) { - newFiber.flags = Placement; + newFiber.flags |= Placement; } return newFiber; } diff --git a/packages/react-reconciler/src/ReactChildFiber.old.js b/packages/react-reconciler/src/ReactChildFiber.old.js index 7313d78f0bf3b..730f08663878c 100644 --- a/packages/react-reconciler/src/ReactChildFiber.old.js +++ b/packages/react-reconciler/src/ReactChildFiber.old.js @@ -342,7 +342,7 @@ function ChildReconciler(shouldTrackSideEffects) { const oldIndex = current.index; if (oldIndex < lastPlacedIndex) { // This is a move. - newFiber.flags = Placement; + newFiber.flags |= Placement; return lastPlacedIndex; } else { // This item can stay in place. @@ -350,7 +350,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } else { // This is an insertion. - newFiber.flags = Placement; + newFiber.flags |= Placement; return lastPlacedIndex; } } @@ -359,7 +359,7 @@ function ChildReconciler(shouldTrackSideEffects) { // This is simpler for the single child case. We only need to do a // placement for inserting new children. if (shouldTrackSideEffects && newFiber.alternate === null) { - newFiber.flags = Placement; + newFiber.flags |= Placement; } return newFiber; }