From 8a00b678dff5acce29577c357e46bae7a12f6057 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Thu, 25 Jul 2019 17:49:57 -0700 Subject: [PATCH] [Bugfix] Check tag before calling hook effects TODO: Test that triggers this --- .../react-reconciler/src/ReactFiberCommitWork.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js index d840173c1195f..221a4d244eb39 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.js @@ -59,6 +59,7 @@ import { Placement, Snapshot, Update, + Passive, } from 'shared/ReactSideEffectTags'; import getComponentName from 'shared/getComponentName'; import invariant from 'shared/invariant'; @@ -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(