Add missing param to safelyCallDestroy() (#19638)

This commit is contained in:
Brian Vaughn 2020-08-18 12:02:04 -04:00 committed by GitHub
parent 24f1923b1b
commit 23595ff593
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -323,7 +323,11 @@ function commitBeforeMutationLifeCycles(
); );
} }
function commitHookEffectListUnmount(tag: HookEffectTag, finishedWork: Fiber) { function commitHookEffectListUnmount(
tag: HookEffectTag,
finishedWork: Fiber,
nearestMountedAncestor: Fiber | null,
) {
const updateQueue: FunctionComponentUpdateQueue | null = (finishedWork.updateQueue: any); const updateQueue: FunctionComponentUpdateQueue | null = (finishedWork.updateQueue: any);
const lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; const lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
if (lastEffect !== null) { if (lastEffect !== null) {
@ -335,7 +339,7 @@ function commitHookEffectListUnmount(tag: HookEffectTag, finishedWork: Fiber) {
const destroy = effect.destroy; const destroy = effect.destroy;
effect.destroy = undefined; effect.destroy = undefined;
if (destroy !== undefined) { if (destroy !== undefined) {
safelyCallDestroy(finishedWork, destroy); safelyCallDestroy(finishedWork, nearestMountedAncestor, destroy);
} }
} }
effect = effect.next; effect = effect.next;
@ -1598,12 +1602,17 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
commitHookEffectListUnmount( commitHookEffectListUnmount(
HookLayout | HookHasEffect, HookLayout | HookHasEffect,
finishedWork, finishedWork,
finishedWork.return,
); );
} finally { } finally {
recordLayoutEffectDuration(finishedWork); recordLayoutEffectDuration(finishedWork);
} }
} else { } else {
commitHookEffectListUnmount(HookLayout | HookHasEffect, finishedWork); commitHookEffectListUnmount(
HookLayout | HookHasEffect,
finishedWork,
finishedWork.return,
);
} }
return; return;
} }
@ -1658,12 +1667,20 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
) { ) {
try { try {
startLayoutEffectTimer(); startLayoutEffectTimer();
commitHookEffectListUnmount(HookLayout | HookHasEffect, finishedWork); commitHookEffectListUnmount(
HookLayout | HookHasEffect,
finishedWork,
finishedWork.return,
);
} finally { } finally {
recordLayoutEffectDuration(finishedWork); recordLayoutEffectDuration(finishedWork);
} }
} else { } else {
commitHookEffectListUnmount(HookLayout | HookHasEffect, finishedWork); commitHookEffectListUnmount(
HookLayout | HookHasEffect,
finishedWork,
finishedWork.return,
);
} }
return; return;
} }