Skip to content

Commit 23595ff

Browse files
author
Brian Vaughn
authored
Add missing param to safelyCallDestroy() (#19638)
1 parent 24f1923 commit 23595ff

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

packages/react-reconciler/src/ReactFiberCommitWork.new.js

+22-5
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,11 @@ function commitBeforeMutationLifeCycles(
323323
);
324324
}
325325

326-
function commitHookEffectListUnmount(tag: HookEffectTag, finishedWork: Fiber) {
326+
function commitHookEffectListUnmount(
327+
tag: HookEffectTag,
328+
finishedWork: Fiber,
329+
nearestMountedAncestor: Fiber | null,
330+
) {
327331
const updateQueue: FunctionComponentUpdateQueue | null = (finishedWork.updateQueue: any);
328332
const lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
329333
if (lastEffect !== null) {
@@ -335,7 +339,7 @@ function commitHookEffectListUnmount(tag: HookEffectTag, finishedWork: Fiber) {
335339
const destroy = effect.destroy;
336340
effect.destroy = undefined;
337341
if (destroy !== undefined) {
338-
safelyCallDestroy(finishedWork, destroy);
342+
safelyCallDestroy(finishedWork, nearestMountedAncestor, destroy);
339343
}
340344
}
341345
effect = effect.next;
@@ -1598,12 +1602,17 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
15981602
commitHookEffectListUnmount(
15991603
HookLayout | HookHasEffect,
16001604
finishedWork,
1605+
finishedWork.return,
16011606
);
16021607
} finally {
16031608
recordLayoutEffectDuration(finishedWork);
16041609
}
16051610
} else {
1606-
commitHookEffectListUnmount(HookLayout | HookHasEffect, finishedWork);
1611+
commitHookEffectListUnmount(
1612+
HookLayout | HookHasEffect,
1613+
finishedWork,
1614+
finishedWork.return,
1615+
);
16071616
}
16081617
return;
16091618
}
@@ -1658,12 +1667,20 @@ function commitWork(current: Fiber | null, finishedWork: Fiber): void {
16581667
) {
16591668
try {
16601669
startLayoutEffectTimer();
1661-
commitHookEffectListUnmount(HookLayout | HookHasEffect, finishedWork);
1670+
commitHookEffectListUnmount(
1671+
HookLayout | HookHasEffect,
1672+
finishedWork,
1673+
finishedWork.return,
1674+
);
16621675
} finally {
16631676
recordLayoutEffectDuration(finishedWork);
16641677
}
16651678
} else {
1666-
commitHookEffectListUnmount(HookLayout | HookHasEffect, finishedWork);
1679+
commitHookEffectListUnmount(
1680+
HookLayout | HookHasEffect,
1681+
finishedWork,
1682+
finishedWork.return,
1683+
);
16671684
}
16681685
return;
16691686
}

0 commit comments

Comments
 (0)