Skip to content

Commit 1377e46

Browse files
authoredDec 7, 2020
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.
1 parent 18d7574 commit 1377e46

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed
 

‎packages/react-reconciler/src/ReactChildFiber.new.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,15 @@ function ChildReconciler(shouldTrackSideEffects) {
342342
const oldIndex = current.index;
343343
if (oldIndex < lastPlacedIndex) {
344344
// This is a move.
345-
newFiber.flags = Placement;
345+
newFiber.flags |= Placement;
346346
return lastPlacedIndex;
347347
} else {
348348
// This item can stay in place.
349349
return oldIndex;
350350
}
351351
} else {
352352
// This is an insertion.
353-
newFiber.flags = Placement;
353+
newFiber.flags |= Placement;
354354
return lastPlacedIndex;
355355
}
356356
}
@@ -359,7 +359,7 @@ function ChildReconciler(shouldTrackSideEffects) {
359359
// This is simpler for the single child case. We only need to do a
360360
// placement for inserting new children.
361361
if (shouldTrackSideEffects && newFiber.alternate === null) {
362-
newFiber.flags = Placement;
362+
newFiber.flags |= Placement;
363363
}
364364
return newFiber;
365365
}

‎packages/react-reconciler/src/ReactChildFiber.old.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,15 @@ function ChildReconciler(shouldTrackSideEffects) {
342342
const oldIndex = current.index;
343343
if (oldIndex < lastPlacedIndex) {
344344
// This is a move.
345-
newFiber.flags = Placement;
345+
newFiber.flags |= Placement;
346346
return lastPlacedIndex;
347347
} else {
348348
// This item can stay in place.
349349
return oldIndex;
350350
}
351351
} else {
352352
// This is an insertion.
353-
newFiber.flags = Placement;
353+
newFiber.flags |= Placement;
354354
return lastPlacedIndex;
355355
}
356356
}
@@ -359,7 +359,7 @@ function ChildReconciler(shouldTrackSideEffects) {
359359
// This is simpler for the single child case. We only need to do a
360360
// placement for inserting new children.
361361
if (shouldTrackSideEffects && newFiber.alternate === null) {
362-
newFiber.flags = Placement;
362+
newFiber.flags |= Placement;
363363
}
364364
return newFiber;
365365
}

0 commit comments

Comments
 (0)