Skip to content

Commit

Permalink
[Bugfix] Check tag before calling hook effects
Browse files Browse the repository at this point in the history
TODO: Test that triggers this
  • Loading branch information
acdlite committed Jul 26, 2019
1 parent c0830a0 commit 8a00b67
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/react-reconciler/src/ReactFiberCommitWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import {
Placement,
Snapshot,
Update,
Passive,
} from 'shared/ReactSideEffectTags';
import getComponentName from 'shared/getComponentName';
import invariant from 'shared/invariant';
Expand Down Expand Up @@ -383,8 +384,19 @@ function commitHookEffectList(
}

export function commitPassiveHookEffects(finishedWork: Fiber): void {
commitHookEffectList(UnmountPassive, NoHookEffect, finishedWork);
commitHookEffectList(NoHookEffect, MountPassive, finishedWork);
if (finishedWork.effectTag & Passive) {
switch (finishedWork.tag) {
case FunctionComponent:
case ForwardRef:
case SimpleMemoComponent: {
commitHookEffectList(UnmountPassive, NoHookEffect, finishedWork);
commitHookEffectList(NoHookEffect, MountPassive, finishedWork);
break;
}
default:
break;
}
}
}

function commitLifeCycles(
Expand Down

0 comments on commit 8a00b67

Please sign in to comment.