Skip to content

Commit

Permalink
Remove PassiveStatic optimization
Browse files Browse the repository at this point in the history
Passive flags are a new concept that is tricky to get right. We've
already found two bugs related to PassiveStatic. Let's remove this
optimization for now, and add it back once the main part of the effects
refactor lands.
  • Loading branch information
acdlite committed Dec 18, 2020
1 parent a6329b1 commit 00a5b08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
13 changes: 6 additions & 7 deletions packages/react-reconciler/src/ReactFiberCommitWork.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ import {
Snapshot,
Update,
Passive,
PassiveStatic,
PassiveMask,
PassiveUnmountPendingDev,
} from './ReactFiberFlags';
Expand Down Expand Up @@ -2007,7 +2006,8 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(
while (nextEffect !== null) {
const fiber = nextEffect;
const child = fiber.child;
if ((fiber.subtreeFlags & PassiveStatic) !== NoFlags && child !== null) {
// TODO: Only traverse subtree if it has a PassiveStatic flag
if (child !== null) {
ensureCorrectReturnPointer(child, fiber);
nextEffect = child;
} else {
Expand All @@ -2023,11 +2023,10 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_complete(
) {
while (nextEffect !== null) {
const fiber = nextEffect;
if ((fiber.flags & PassiveStatic) !== NoFlags) {
setCurrentDebugFiberInDEV(fiber);
commitPassiveUnmountInsideDeletedTreeOnFiber(fiber);
resetCurrentDebugFiberInDEV();
}
// TODO: Check if fiber has a PassiveStatic flag
setCurrentDebugFiberInDEV(fiber);
commitPassiveUnmountInsideDeletedTreeOnFiber(fiber);
resetCurrentDebugFiberInDEV();

if (fiber === deletedSubtreeRoot) {
nextEffect = null;
Expand Down
13 changes: 6 additions & 7 deletions packages/react-reconciler/src/ReactFiberCommitWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ import {
Snapshot,
Update,
Passive,
PassiveStatic,
PassiveMask,
PassiveUnmountPendingDev,
} from './ReactFiberFlags';
Expand Down Expand Up @@ -2007,7 +2006,8 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_begin(
while (nextEffect !== null) {
const fiber = nextEffect;
const child = fiber.child;
if ((fiber.subtreeFlags & PassiveStatic) !== NoFlags && child !== null) {
// TODO: Only traverse subtree if it has a PassiveStatic flag
if (child !== null) {
ensureCorrectReturnPointer(child, fiber);
nextEffect = child;
} else {
Expand All @@ -2023,11 +2023,10 @@ function commitPassiveUnmountEffectsInsideOfDeletedTree_complete(
) {
while (nextEffect !== null) {
const fiber = nextEffect;
if ((fiber.flags & PassiveStatic) !== NoFlags) {
setCurrentDebugFiberInDEV(fiber);
commitPassiveUnmountInsideDeletedTreeOnFiber(fiber);
resetCurrentDebugFiberInDEV();
}
// TODO: Check if fiber has a PassiveStatic flag
setCurrentDebugFiberInDEV(fiber);
commitPassiveUnmountInsideDeletedTreeOnFiber(fiber);
resetCurrentDebugFiberInDEV();

if (fiber === deletedSubtreeRoot) {
nextEffect = null;
Expand Down

0 comments on commit 00a5b08

Please sign in to comment.