@samitouri / QOS-React-2 / commits / 84558c61ba

Don't visit passive effects during layout phase (#19809)

Removes the `Update` flag when scheduling a passive effect for `useEffect`. The `Passive` flag alone is sufficient. This doesn't affect any behavior, but does optimize the performance of the commit phase.

Andrew Clark committed Sep 10, 2020 at 16:00 UTC 84558c61ba1e511768e4f775fcf9c7af3a339caf
2 files changed +4 -10
packages/react-reconciler/src/ReactFiberHooks.new.js
+3 -9
@@ -1241,7 +1241,7 @@ function mountEffect(
1241 }
1242 }
1243 return mountEffectImpl(
1244 - UpdateEffect | PassiveEffect | PassiveStaticEffect,
1244 + PassiveEffect | PassiveStaticEffect,
1245 HookPassive,
1246 create,
1247 deps,
@@ -1258,12 +1258,7 @@ function updateEffect(
1258 warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber);
1259 }
1260 }
1261 - return updateEffectImpl(
1262 - UpdateEffect | PassiveEffect,
1263 - HookPassive,
1264 - create,
1265 - deps,
1266 - );
1261 + return updateEffectImpl(PassiveEffect, HookPassive, create, deps);
1262 }
1263
1264 function mountLayoutEffect(
@@ -1615,8 +1610,7 @@ function mountOpaqueIdentifier(): OpaqueIDType | void {
1610 const setId = mountState(id)[1];
1611
1612 if ((currentlyRenderingFiber.mode & BlockingMode) === NoMode) {
1618 - currentlyRenderingFiber.flags |=
1619 - UpdateEffect | PassiveEffect | PassiveStaticEffect;
1613 + currentlyRenderingFiber.flags |= PassiveEffect | PassiveStaticEffect;
1614 pushEffect(
1615 HookHasEffect | HookPassive,
1616 () => {
packages/react-reconciler/src/ReactFiberWorkLoop.new.js
+1 -1
@@ -2623,7 +2623,7 @@ function flushPassiveMountEffects(firstChild: Fiber): void {
2623 flushPassiveMountEffects(fiber.child);
2624 }
2625
2626 - if ((fiber.flags & Update) !== NoFlags) {
2626 + if ((fiber.flags & Passive) !== NoFlags) {
2627 setCurrentDebugFiberInDEV(fiber);
2628 commitPassiveEffectOnFiber(fiber);
2629 resetCurrentDebugFiberInDEV();