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.
This commit is contained in:
Andrew Clark 2020-09-10 16:00:41 -05:00 committed by GitHub
parent ad8a0a8cd0
commit 84558c61ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 10 deletions

View File

@ -1241,7 +1241,7 @@ function mountEffect(
}
}
return mountEffectImpl(
UpdateEffect | PassiveEffect | PassiveStaticEffect,
PassiveEffect | PassiveStaticEffect,
HookPassive,
create,
deps,
@ -1258,12 +1258,7 @@ function updateEffect(
warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber);
}
}
return updateEffectImpl(
UpdateEffect | PassiveEffect,
HookPassive,
create,
deps,
);
return updateEffectImpl(PassiveEffect, HookPassive, create, deps);
}
function mountLayoutEffect(
@ -1615,8 +1610,7 @@ function mountOpaqueIdentifier(): OpaqueIDType | void {
const setId = mountState(id)[1];
if ((currentlyRenderingFiber.mode & BlockingMode) === NoMode) {
currentlyRenderingFiber.flags |=
UpdateEffect | PassiveEffect | PassiveStaticEffect;
currentlyRenderingFiber.flags |= PassiveEffect | PassiveStaticEffect;
pushEffect(
HookHasEffect | HookPassive,
() => {

View File

@ -2623,7 +2623,7 @@ function flushPassiveMountEffects(firstChild: Fiber): void {
flushPassiveMountEffects(fiber.child);
}
if ((fiber.flags & Update) !== NoFlags) {
if ((fiber.flags & Passive) !== NoFlags) {
setCurrentDebugFiberInDEV(fiber);
commitPassiveEffectOnFiber(fiber);
resetCurrentDebugFiberInDEV();