Check PassiveStatic instead of Passive (#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.
This commit is contained in:
Andrew Clark
2020-07-30 09:13:04 -04:00
committed by GitHub
parent dff97a6915
commit e1f96b82b4
2 changed files with 6 additions and 10 deletions
@@ -68,7 +68,6 @@ import {
Placement,
Snapshot,
Update,
Passive,
} from './ReactSideEffectTags';
import getComponentName from 'shared/getComponentName';
import invariant from 'shared/invariant';
@@ -881,8 +880,6 @@ function commitUnmount(
// TODO: Consider if we can move this block out of the synchronous commit phase
effect.tag |= HookHasEffect;
current.effectTag |= Passive;
schedulePassiveEffectCallback();
} else {
if (
@@ -2836,13 +2836,12 @@ function flushPassiveUnmountEffectsInsideOfDeletedTree(
}
}
switch (fiber.tag) {
case FunctionComponent:
case ForwardRef:
case SimpleMemoComponent:
case Block: {
const primaryEffectTag = fiber.effectTag & Passive;
if (primaryEffectTag !== NoEffect) {
if ((fiber.effectTag & PassiveStatic) !== NoEffect) {
switch (fiber.tag) {
case FunctionComponent:
case ForwardRef:
case SimpleMemoComponent:
case Block: {
flushPassiveUnmountEffectsImpl(fiber);
}
}