Skip to content

Commit e1f96b8

Browse files
authored
Check PassiveStatic instead of Passive (facebook#19489)
Saves us from having to set a flag on `current` during the layout phase. Could result in some redundant traversal, since PassiveStatic includes effects that don't need clean-up. But it's worth it to remove the work from the layout phase. While I was editing this, I also re-arranged it so that we check the `effectTag` check before we check the `tag`, since the `effectTag` check is the one that's more likely to fail.
1 parent dff97a6 commit e1f96b8

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

packages/react-reconciler/src/ReactFiberCommitWork.new.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ import {
6868
Placement,
6969
Snapshot,
7070
Update,
71-
Passive,
7271
} from './ReactSideEffectTags';
7372
import getComponentName from 'shared/getComponentName';
7473
import invariant from 'shared/invariant';
@@ -881,8 +880,6 @@ function commitUnmount(
881880
// TODO: Consider if we can move this block out of the synchronous commit phase
882881
effect.tag |= HookHasEffect;
883882

884-
current.effectTag |= Passive;
885-
886883
schedulePassiveEffectCallback();
887884
} else {
888885
if (

packages/react-reconciler/src/ReactFiberWorkLoop.new.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2836,13 +2836,12 @@ function flushPassiveUnmountEffectsInsideOfDeletedTree(
28362836
}
28372837
}
28382838

2839-
switch (fiber.tag) {
2840-
case FunctionComponent:
2841-
case ForwardRef:
2842-
case SimpleMemoComponent:
2843-
case Block: {
2844-
const primaryEffectTag = fiber.effectTag & Passive;
2845-
if (primaryEffectTag !== NoEffect) {
2839+
if ((fiber.effectTag & PassiveStatic) !== NoEffect) {
2840+
switch (fiber.tag) {
2841+
case FunctionComponent:
2842+
case ForwardRef:
2843+
case SimpleMemoComponent:
2844+
case Block: {
28462845
flushPassiveUnmountEffectsImpl(fiber);
28472846
}
28482847
}

0 commit comments

Comments
 (0)