@samitouri / QOS-React / commits / e1f96b82b4

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.

Andrew Clark committed Jul 30, 2020 at 08:13 UTC e1f96b82b4aff1d5c50d02c76df9c60e32dba408
2 files changed +6 -10
packages/react-reconciler/src/ReactFiberCommitWork.new.js
-3
@@ -68,7 +68,6 @@ import {
68 Placement,
69 Snapshot,
70 Update,
71 - Passive,
71 } from './ReactSideEffectTags';
72 import getComponentName from 'shared/getComponentName';
73 import invariant from 'shared/invariant';
@@ -881,8 +880,6 @@ function commitUnmount(
880 // TODO: Consider if we can move this block out of the synchronous commit phase
881 effect.tag |= HookHasEffect;
882
884 - current.effectTag |= Passive;
885 -
883 schedulePassiveEffectCallback();
884 } else {
885 if (
packages/react-reconciler/src/ReactFiberWorkLoop.new.js
+6 -7
@@ -2836,13 +2836,12 @@ function flushPassiveUnmountEffectsInsideOfDeletedTree(
2836 }
2837 }
2838
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: {
2845 flushPassiveUnmountEffectsImpl(fiber);
2846 }
2847 }