change destroy to safelyCallDestroy (#19605)
We use safelyCallDestroy for commitUnmount and passive effects unmounts but we call destroy directly in commitHookEffectListUnmount (AKA layout effects unmounts because we don't use this anywhere else). This PR changes the direct destroy call to safelyCallDestroy for consistency
Luna Ruan committed
Aug 17, 2020 at 17:32 UTC
ee409ea3b577f9ff37d36ccbfc642058ad783bb0
1 file changed
+1
-1
packages/react-reconciler/src/ReactFiberCommitWork.new.js
+1
-1
@@ -335,7 +335,7 @@ function commitHookEffectListUnmount(tag: HookEffectTag, finishedWork: Fiber) {
335
const destroy = effect.destroy;
336
effect.destroy = undefined;
337
if (destroy !== undefined) {
338
- destroy();
338
+ safelyCallDestroy(finishedWork, destroy);
339
}
340
}
341
effect = effect.next;