Removed skip-error-boundaries modifications from old fork (#19961)
Technically this change is unnecessary, since the feature is controlled by a flag, but since we decided not to ship this in v17– I'm going to remove it for now entirely.
Brian Vaughn committed
Oct 5, 2020 at 15:49 UTC
44d39c4d76c4ea4b26a2160ae6ba861babfb2b14
2 files changed
+35
-101
packages/react-reconciler/src/ReactFiberCommitWork.old.js
+22
-73
@@ -153,11 +153,7 @@ const callComponentWillUnmountWithTimer = function(current, instance) {
153
};
154
155
// Capture errors so they don't interrupt unmounting.
156
-function safelyCallComponentWillUnmount(
157
- current: Fiber,
158
- instance: any,
159
- nearestMountedAncestor: Fiber | null,
160
-) {
156
+function safelyCallComponentWillUnmount(current: Fiber, instance: any) {
157
if (__DEV__) {
158
invokeGuardedCallback(
159
null,
@@ -168,18 +164,18 @@ function safelyCallComponentWillUnmount(
164
);
165
if (hasCaughtError()) {
166
const unmountError = clearCaughtError();
171
- captureCommitPhaseError(current, nearestMountedAncestor, unmountError);
167
+ captureCommitPhaseError(current, unmountError);
168
}
169
} else {
170
try {
171
callComponentWillUnmountWithTimer(current, instance);
172
} catch (unmountError) {
177
- captureCommitPhaseError(current, nearestMountedAncestor, unmountError);
173
+ captureCommitPhaseError(current, unmountError);
174
}
175
}
176
}
177
182
-function safelyDetachRef(current: Fiber, nearestMountedAncestor: Fiber | null) {
178
+function safelyDetachRef(current: Fiber) {
179
const ref = current.ref;
180
if (ref !== null) {
181
if (typeof ref === 'function') {
@@ -187,13 +183,13 @@ function safelyDetachRef(current: Fiber, nearestMountedAncestor: Fiber | null) {
183
invokeGuardedCallback(null, ref, null, null);
184
if (hasCaughtError()) {
185
const refError = clearCaughtError();
190
- captureCommitPhaseError(current, nearestMountedAncestor, refError);
186
+ captureCommitPhaseError(current, refError);
187
}
188
} else {
189
try {
190
ref(null);
191
} catch (refError) {
196
- captureCommitPhaseError(current, nearestMountedAncestor, refError);
192
+ captureCommitPhaseError(current, refError);
193
}
194
}
195
} else {
@@ -202,22 +198,18 @@ function safelyDetachRef(current: Fiber, nearestMountedAncestor: Fiber | null) {
198
}
199
}
200
205
-function safelyCallDestroy(
206
- current: Fiber,
207
- nearestMountedAncestor: Fiber | null,
208
- destroy: () => void,
209
-) {
201
+function safelyCallDestroy(current: Fiber, destroy: () => void) {
202
if (__DEV__) {
203
invokeGuardedCallback(null, destroy, null);
204
if (hasCaughtError()) {
205
const error = clearCaughtError();
214
- captureCommitPhaseError(current, nearestMountedAncestor, error);
206
+ captureCommitPhaseError(current, error);
207
}
208
} else {
209
try {
210
destroy();
211
} catch (error) {
220
- captureCommitPhaseError(current, nearestMountedAncestor, error);
212
+ captureCommitPhaseError(current, error);
213
}
214
}
215
}
@@ -874,7 +866,6 @@ function commitDetachRef(current: Fiber) {
866
function commitUnmount(
867
finishedRoot: FiberRoot,
868
current: Fiber,
877
- nearestMountedAncestor: Fiber | null,
869
renderPriorityLevel: ReactPriorityLevel,
870
): void {
871
onCommitUnmount(current);
@@ -904,10 +895,10 @@ function commitUnmount(
895
current.mode & ProfileMode
896
) {
897
startLayoutEffectTimer();
907
- safelyCallDestroy(current, nearestMountedAncestor, destroy);
898
+ safelyCallDestroy(current, destroy);
899
recordLayoutEffectDuration(current);
900
} else {
910
- safelyCallDestroy(current, nearestMountedAncestor, destroy);
901
+ safelyCallDestroy(current, destroy);
902
}
903
}
904
}
@@ -918,19 +909,15 @@ function commitUnmount(
909
return;
910
}
911
case ClassComponent: {
921
- safelyDetachRef(current, nearestMountedAncestor);
912
+ safelyDetachRef(current);
913
const instance = current.stateNode;
914
if (typeof instance.componentWillUnmount === 'function') {
924
- safelyCallComponentWillUnmount(
925
- current,
926
- instance,
927
- nearestMountedAncestor,
928
- );
915
+ safelyCallComponentWillUnmount(current, instance);
916
}
917
return;
918
}
919
case HostComponent: {
933
- safelyDetachRef(current, nearestMountedAncestor);
920
+ safelyDetachRef(current);
921
return;
922
}
923
case HostPortal: {
@@ -938,12 +925,7 @@ function commitUnmount(
925
// We are also not using this parent because
926
// the portal will get pushed immediately.
927
if (supportsMutation) {
941
- unmountHostComponents(
942
- finishedRoot,
943
- current,
944
- nearestMountedAncestor,
945
- renderPriorityLevel,
946
- );
928
+ unmountHostComponents(finishedRoot, current, renderPriorityLevel);
929
} else if (supportsPersistence) {
930
emptyPortalContainer(current);
931
}
@@ -973,7 +955,7 @@ function commitUnmount(
955
}
956
case ScopeComponent: {
957
if (enableScopeAPI) {
976
- safelyDetachRef(current, nearestMountedAncestor);
958
+ safelyDetachRef(current);
959
}
960
return;
961
}
@@ -983,7 +965,6 @@ function commitUnmount(
965
function commitNestedUnmounts(
966
finishedRoot: FiberRoot,
967
root: Fiber,
986
- nearestMountedAncestor: Fiber | null,
968
renderPriorityLevel: ReactPriorityLevel,
969
): void {
970
// While we're inside a removed host node we don't want to call
@@ -993,12 +974,7 @@ function commitNestedUnmounts(
974
// we do an inner loop while we're still inside the host node.
975
let node: Fiber = root;
976
while (true) {
996
- commitUnmount(
997
- finishedRoot,
998
- node,
999
- nearestMountedAncestor,
1000
- renderPriorityLevel,
1001
- );
977
+ commitUnmount(finishedRoot, node, renderPriorityLevel);
978
// Visit children because they may contain more composite or host nodes.
979
// Skip portals because commitUnmount() currently visits them recursively.
980
if (
@@ -1289,7 +1265,6 @@ function insertOrAppendPlacementNode(
1265
function unmountHostComponents(
1266
finishedRoot: FiberRoot,
1267
current: Fiber,
1292
- nearestMountedAncestor: Fiber | null,
1268
renderPriorityLevel: ReactPriorityLevel,
1269
): void {
1270
// We only have the top Fiber that was deleted but we need to recurse down its
@@ -1339,12 +1314,7 @@ function unmountHostComponents(
1314
}
1315
1316
if (node.tag === HostComponent || node.tag === HostText) {
1342
- commitNestedUnmounts(
1343
- finishedRoot,
1344
- node,
1345
- nearestMountedAncestor,
1346
- renderPriorityLevel,
1347
- );
1317
+ commitNestedUnmounts(finishedRoot, node, renderPriorityLevel);
1318
// After all the children have unmounted, it is now safe to remove the
1319
// node from the tree.
1320
if (currentParentIsContainer) {
@@ -1361,12 +1331,7 @@ function unmountHostComponents(
1331
// Don't visit children because we already visited them.
1332
} else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
1333
const fundamentalNode = node.stateNode.instance;
1364
- commitNestedUnmounts(
1365
- finishedRoot,
1366
- node,
1367
- nearestMountedAncestor,
1368
- renderPriorityLevel,
1369
- );
1334
+ commitNestedUnmounts(finishedRoot, node, renderPriorityLevel);
1335
// After all the children have unmounted, it is now safe to remove the
1336
// node from the tree.
1337
if (currentParentIsContainer) {
@@ -1418,12 +1383,7 @@ function unmountHostComponents(
1383
continue;
1384
}
1385
} else {
1421
- commitUnmount(
1422
- finishedRoot,
1423
- node,
1424
- nearestMountedAncestor,
1425
- renderPriorityLevel,
1426
- );
1386
+ commitUnmount(finishedRoot, node, renderPriorityLevel);
1387
// Visit children because we may find more host components below.
1388
if (node.child !== null) {
1389
node.child.return = node;
@@ -1453,26 +1413,15 @@ function unmountHostComponents(
1413
function commitDeletion(
1414
finishedRoot: FiberRoot,
1415
current: Fiber,
1456
- nearestMountedAncestor: Fiber | null,
1416
renderPriorityLevel: ReactPriorityLevel,
1417
): void {
1418
if (supportsMutation) {
1419
// Recursively delete all host nodes from the parent.
1420
// Detach refs and call componentWillUnmount() on the whole subtree.
1462
- unmountHostComponents(
1463
- finishedRoot,
1464
- current,
1465
- nearestMountedAncestor,
1466
- renderPriorityLevel,
1467
- );
1421
+ unmountHostComponents(finishedRoot, current, renderPriorityLevel);
1422
} else {
1423
// Detach refs and call componentWillUnmount() on the whole subtree.
1470
- commitNestedUnmounts(
1471
- finishedRoot,
1472
- current,
1473
- nearestMountedAncestor,
1474
- renderPriorityLevel,
1475
- );
1424
+ commitNestedUnmounts(finishedRoot, current, renderPriorityLevel);
1425
}
1426
const alternate = current.alternate;
1427
detachFiberMutation(current);
packages/react-reconciler/src/ReactFiberWorkLoop.old.js
+13
-28
@@ -29,7 +29,6 @@ import {
29
enableDebugTracing,
30
enableSchedulingProfiler,
31
enableScopeAPI,
32
- skipUnmountedBoundaries,
32
} from 'shared/ReactFeatureFlags';
33
import ReactSharedInternals from 'shared/ReactSharedInternals';
34
import invariant from 'shared/invariant';
@@ -2019,7 +2018,7 @@ function commitRootImpl(root, renderPriorityLevel) {
2018
if (hasCaughtError()) {
2019
invariant(nextEffect !== null, 'Should be working on an effect.');
2020
const error = clearCaughtError();
2022
- captureCommitPhaseError(nextEffect, nextEffect.return, error);
2021
+ captureCommitPhaseError(nextEffect, error);
2022
nextEffect = nextEffect.nextEffect;
2023
}
2024
} else {
@@ -2027,7 +2026,7 @@ function commitRootImpl(root, renderPriorityLevel) {
2026
commitBeforeMutationEffects();
2027
} catch (error) {
2028
invariant(nextEffect !== null, 'Should be working on an effect.');
2030
- captureCommitPhaseError(nextEffect, nextEffect.return, error);
2029
+ captureCommitPhaseError(nextEffect, error);
2030
nextEffect = nextEffect.nextEffect;
2031
}
2032
}
@@ -2056,7 +2055,7 @@ function commitRootImpl(root, renderPriorityLevel) {
2055
if (hasCaughtError()) {
2056
invariant(nextEffect !== null, 'Should be working on an effect.');
2057
const error = clearCaughtError();
2059
- captureCommitPhaseError(nextEffect, nextEffect.return, error);
2058
+ captureCommitPhaseError(nextEffect, error);
2059
nextEffect = nextEffect.nextEffect;
2060
}
2061
} else {
@@ -2064,7 +2063,7 @@ function commitRootImpl(root, renderPriorityLevel) {
2063
commitMutationEffects(root, renderPriorityLevel);
2064
} catch (error) {
2065
invariant(nextEffect !== null, 'Should be working on an effect.');
2067
- captureCommitPhaseError(nextEffect, nextEffect.return, error);
2066
+ captureCommitPhaseError(nextEffect, error);
2067
nextEffect = nextEffect.nextEffect;
2068
}
2069
}
@@ -2091,7 +2090,7 @@ function commitRootImpl(root, renderPriorityLevel) {
2090
if (hasCaughtError()) {
2091
invariant(nextEffect !== null, 'Should be working on an effect.');
2092
const error = clearCaughtError();
2094
- captureCommitPhaseError(nextEffect, nextEffect.return, error);
2093
+ captureCommitPhaseError(nextEffect, error);
2094
nextEffect = nextEffect.nextEffect;
2095
}
2096
} else {
@@ -2099,7 +2098,7 @@ function commitRootImpl(root, renderPriorityLevel) {
2098
commitLayoutEffects(root, lanes);
2099
} catch (error) {
2100
invariant(nextEffect !== null, 'Should be working on an effect.');
2102
- captureCommitPhaseError(nextEffect, nextEffect.return, error);
2101
+ captureCommitPhaseError(nextEffect, error);
2102
nextEffect = nextEffect.nextEffect;
2103
}
2104
}
@@ -2373,12 +2372,7 @@ function commitMutationEffects(
2372
break;
2373
}
2374
case Deletion: {
2376
- commitDeletion(
2377
- root,
2378
- nextEffect,
2379
- nextEffect.return,
2380
- renderPriorityLevel,
2381
- );
2375
+ commitDeletion(root, nextEffect, renderPriorityLevel);
2376
break;
2377
}
2378
}
@@ -2589,7 +2583,7 @@ function flushPassiveEffectsImpl() {
2583
if (hasCaughtError()) {
2584
invariant(fiber !== null, 'Should be working on an effect.');
2585
const error = clearCaughtError();
2592
- captureCommitPhaseError(fiber, fiber.return, error);
2586
+ captureCommitPhaseError(fiber, error);
2587
}
2588
resetCurrentDebugFiberInDEV();
2589
} else {
@@ -2610,7 +2604,7 @@ function flushPassiveEffectsImpl() {
2604
}
2605
} catch (error) {
2606
invariant(fiber !== null, 'Should be working on an effect.');
2613
- captureCommitPhaseError(fiber, fiber.return, error);
2607
+ captureCommitPhaseError(fiber, error);
2608
}
2609
}
2610
}
@@ -2637,7 +2631,7 @@ function flushPassiveEffectsImpl() {
2631
if (hasCaughtError()) {
2632
invariant(fiber !== null, 'Should be working on an effect.');
2633
const error = clearCaughtError();
2640
- captureCommitPhaseError(fiber, fiber.return, error);
2634
+ captureCommitPhaseError(fiber, error);
2635
}
2636
resetCurrentDebugFiberInDEV();
2637
} else {
@@ -2659,7 +2653,7 @@ function flushPassiveEffectsImpl() {
2653
}
2654
} catch (error) {
2655
invariant(fiber !== null, 'Should be working on an effect.');
2662
- captureCommitPhaseError(fiber, fiber.return, error);
2656
+ captureCommitPhaseError(fiber, error);
2657
}
2658
}
2659
}
@@ -2758,11 +2752,7 @@ function captureCommitPhaseErrorOnRoot(
2752
}
2753
}
2754
2761
-export function captureCommitPhaseError(
2762
- sourceFiber: Fiber,
2763
- nearestMountedAncestor: Fiber | null,
2764
- error: mixed,
2765
-) {
2755
+export function captureCommitPhaseError(sourceFiber: Fiber, error: mixed) {
2756
if (sourceFiber.tag === HostRoot) {
2757
// Error was thrown at the root. There is no parent, so the root
2758
// itself should capture it.
@@ -2770,12 +2760,7 @@ export function captureCommitPhaseError(
2760
return;
2761
}
2762
2773
- let fiber = null;
2774
- if (skipUnmountedBoundaries) {
2775
- fiber = nearestMountedAncestor;
2776
- } else {
2777
- fiber = sourceFiber.return;
2778
- }
2763
+ let fiber = sourceFiber.return;
2764
2765
while (fiber !== null) {
2766
if (fiber.tag === HostRoot) {