mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user