Skip to content

Commit 44d39c4

Browse files
author
Brian Vaughn
authoredOct 5, 2020
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.
1 parent 461cd84 commit 44d39c4

File tree

2 files changed

+35
-101
lines changed

2 files changed

+35
-101
lines changed
 

‎packages/react-reconciler/src/ReactFiberCommitWork.old.js

+22-73
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,7 @@ const callComponentWillUnmountWithTimer = function(current, instance) {
153153
};
154154

155155
// 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) {
161157
if (__DEV__) {
162158
invokeGuardedCallback(
163159
null,
@@ -168,32 +164,32 @@ function safelyCallComponentWillUnmount(
168164
);
169165
if (hasCaughtError()) {
170166
const unmountError = clearCaughtError();
171-
captureCommitPhaseError(current, nearestMountedAncestor, unmountError);
167+
captureCommitPhaseError(current, unmountError);
172168
}
173169
} else {
174170
try {
175171
callComponentWillUnmountWithTimer(current, instance);
176172
} catch (unmountError) {
177-
captureCommitPhaseError(current, nearestMountedAncestor, unmountError);
173+
captureCommitPhaseError(current, unmountError);
178174
}
179175
}
180176
}
181177

182-
function safelyDetachRef(current: Fiber, nearestMountedAncestor: Fiber | null) {
178+
function safelyDetachRef(current: Fiber) {
183179
const ref = current.ref;
184180
if (ref !== null) {
185181
if (typeof ref === 'function') {
186182
if (__DEV__) {
187183
invokeGuardedCallback(null, ref, null, null);
188184
if (hasCaughtError()) {
189185
const refError = clearCaughtError();
190-
captureCommitPhaseError(current, nearestMountedAncestor, refError);
186+
captureCommitPhaseError(current, refError);
191187
}
192188
} else {
193189
try {
194190
ref(null);
195191
} catch (refError) {
196-
captureCommitPhaseError(current, nearestMountedAncestor, refError);
192+
captureCommitPhaseError(current, refError);
197193
}
198194
}
199195
} else {
@@ -202,22 +198,18 @@ function safelyDetachRef(current: Fiber, nearestMountedAncestor: Fiber | null) {
202198
}
203199
}
204200

205-
function safelyCallDestroy(
206-
current: Fiber,
207-
nearestMountedAncestor: Fiber | null,
208-
destroy: () => void,
209-
) {
201+
function safelyCallDestroy(current: Fiber, destroy: () => void) {
210202
if (__DEV__) {
211203
invokeGuardedCallback(null, destroy, null);
212204
if (hasCaughtError()) {
213205
const error = clearCaughtError();
214-
captureCommitPhaseError(current, nearestMountedAncestor, error);
206+
captureCommitPhaseError(current, error);
215207
}
216208
} else {
217209
try {
218210
destroy();
219211
} catch (error) {
220-
captureCommitPhaseError(current, nearestMountedAncestor, error);
212+
captureCommitPhaseError(current, error);
221213
}
222214
}
223215
}
@@ -874,7 +866,6 @@ function commitDetachRef(current: Fiber) {
874866
function commitUnmount(
875867
finishedRoot: FiberRoot,
876868
current: Fiber,
877-
nearestMountedAncestor: Fiber | null,
878869
renderPriorityLevel: ReactPriorityLevel,
879870
): void {
880871
onCommitUnmount(current);
@@ -904,10 +895,10 @@ function commitUnmount(
904895
current.mode & ProfileMode
905896
) {
906897
startLayoutEffectTimer();
907-
safelyCallDestroy(current, nearestMountedAncestor, destroy);
898+
safelyCallDestroy(current, destroy);
908899
recordLayoutEffectDuration(current);
909900
} else {
910-
safelyCallDestroy(current, nearestMountedAncestor, destroy);
901+
safelyCallDestroy(current, destroy);
911902
}
912903
}
913904
}
@@ -918,32 +909,23 @@ function commitUnmount(
918909
return;
919910
}
920911
case ClassComponent: {
921-
safelyDetachRef(current, nearestMountedAncestor);
912+
safelyDetachRef(current);
922913
const instance = current.stateNode;
923914
if (typeof instance.componentWillUnmount === 'function') {
924-
safelyCallComponentWillUnmount(
925-
current,
926-
instance,
927-
nearestMountedAncestor,
928-
);
915+
safelyCallComponentWillUnmount(current, instance);
929916
}
930917
return;
931918
}
932919
case HostComponent: {
933-
safelyDetachRef(current, nearestMountedAncestor);
920+
safelyDetachRef(current);
934921
return;
935922
}
936923
case HostPortal: {
937924
// TODO: this is recursive.
938925
// We are also not using this parent because
939926
// the portal will get pushed immediately.
940927
if (supportsMutation) {
941-
unmountHostComponents(
942-
finishedRoot,
943-
current,
944-
nearestMountedAncestor,
945-
renderPriorityLevel,
946-
);
928+
unmountHostComponents(finishedRoot, current, renderPriorityLevel);
947929
} else if (supportsPersistence) {
948930
emptyPortalContainer(current);
949931
}
@@ -973,7 +955,7 @@ function commitUnmount(
973955
}
974956
case ScopeComponent: {
975957
if (enableScopeAPI) {
976-
safelyDetachRef(current, nearestMountedAncestor);
958+
safelyDetachRef(current);
977959
}
978960
return;
979961
}
@@ -983,7 +965,6 @@ function commitUnmount(
983965
function commitNestedUnmounts(
984966
finishedRoot: FiberRoot,
985967
root: Fiber,
986-
nearestMountedAncestor: Fiber | null,
987968
renderPriorityLevel: ReactPriorityLevel,
988969
): void {
989970
// While we're inside a removed host node we don't want to call
@@ -993,12 +974,7 @@ function commitNestedUnmounts(
993974
// we do an inner loop while we're still inside the host node.
994975
let node: Fiber = root;
995976
while (true) {
996-
commitUnmount(
997-
finishedRoot,
998-
node,
999-
nearestMountedAncestor,
1000-
renderPriorityLevel,
1001-
);
977+
commitUnmount(finishedRoot, node, renderPriorityLevel);
1002978
// Visit children because they may contain more composite or host nodes.
1003979
// Skip portals because commitUnmount() currently visits them recursively.
1004980
if (
@@ -1289,7 +1265,6 @@ function insertOrAppendPlacementNode(
12891265
function unmountHostComponents(
12901266
finishedRoot: FiberRoot,
12911267
current: Fiber,
1292-
nearestMountedAncestor: Fiber | null,
12931268
renderPriorityLevel: ReactPriorityLevel,
12941269
): void {
12951270
// We only have the top Fiber that was deleted but we need to recurse down its
@@ -1339,12 +1314,7 @@ function unmountHostComponents(
13391314
}
13401315

13411316
if (node.tag === HostComponent || node.tag === HostText) {
1342-
commitNestedUnmounts(
1343-
finishedRoot,
1344-
node,
1345-
nearestMountedAncestor,
1346-
renderPriorityLevel,
1347-
);
1317+
commitNestedUnmounts(finishedRoot, node, renderPriorityLevel);
13481318
// After all the children have unmounted, it is now safe to remove the
13491319
// node from the tree.
13501320
if (currentParentIsContainer) {
@@ -1361,12 +1331,7 @@ function unmountHostComponents(
13611331
// Don't visit children because we already visited them.
13621332
} else if (enableFundamentalAPI && node.tag === FundamentalComponent) {
13631333
const fundamentalNode = node.stateNode.instance;
1364-
commitNestedUnmounts(
1365-
finishedRoot,
1366-
node,
1367-
nearestMountedAncestor,
1368-
renderPriorityLevel,
1369-
);
1334+
commitNestedUnmounts(finishedRoot, node, renderPriorityLevel);
13701335
// After all the children have unmounted, it is now safe to remove the
13711336
// node from the tree.
13721337
if (currentParentIsContainer) {
@@ -1418,12 +1383,7 @@ function unmountHostComponents(
14181383
continue;
14191384
}
14201385
} else {
1421-
commitUnmount(
1422-
finishedRoot,
1423-
node,
1424-
nearestMountedAncestor,
1425-
renderPriorityLevel,
1426-
);
1386+
commitUnmount(finishedRoot, node, renderPriorityLevel);
14271387
// Visit children because we may find more host components below.
14281388
if (node.child !== null) {
14291389
node.child.return = node;
@@ -1453,26 +1413,15 @@ function unmountHostComponents(
14531413
function commitDeletion(
14541414
finishedRoot: FiberRoot,
14551415
current: Fiber,
1456-
nearestMountedAncestor: Fiber | null,
14571416
renderPriorityLevel: ReactPriorityLevel,
14581417
): void {
14591418
if (supportsMutation) {
14601419
// Recursively delete all host nodes from the parent.
14611420
// 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);
14681422
} else {
14691423
// 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);
14761425
}
14771426
const alternate = current.alternate;
14781427
detachFiberMutation(current);

‎packages/react-reconciler/src/ReactFiberWorkLoop.old.js

+13-28
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import {
2929
enableDebugTracing,
3030
enableSchedulingProfiler,
3131
enableScopeAPI,
32-
skipUnmountedBoundaries,
3332
} from 'shared/ReactFeatureFlags';
3433
import ReactSharedInternals from 'shared/ReactSharedInternals';
3534
import invariant from 'shared/invariant';
@@ -2019,15 +2018,15 @@ function commitRootImpl(root, renderPriorityLevel) {
20192018
if (hasCaughtError()) {
20202019
invariant(nextEffect !== null, 'Should be working on an effect.');
20212020
const error = clearCaughtError();
2022-
captureCommitPhaseError(nextEffect, nextEffect.return, error);
2021+
captureCommitPhaseError(nextEffect, error);
20232022
nextEffect = nextEffect.nextEffect;
20242023
}
20252024
} else {
20262025
try {
20272026
commitBeforeMutationEffects();
20282027
} catch (error) {
20292028
invariant(nextEffect !== null, 'Should be working on an effect.');
2030-
captureCommitPhaseError(nextEffect, nextEffect.return, error);
2029+
captureCommitPhaseError(nextEffect, error);
20312030
nextEffect = nextEffect.nextEffect;
20322031
}
20332032
}
@@ -2056,15 +2055,15 @@ function commitRootImpl(root, renderPriorityLevel) {
20562055
if (hasCaughtError()) {
20572056
invariant(nextEffect !== null, 'Should be working on an effect.');
20582057
const error = clearCaughtError();
2059-
captureCommitPhaseError(nextEffect, nextEffect.return, error);
2058+
captureCommitPhaseError(nextEffect, error);
20602059
nextEffect = nextEffect.nextEffect;
20612060
}
20622061
} else {
20632062
try {
20642063
commitMutationEffects(root, renderPriorityLevel);
20652064
} catch (error) {
20662065
invariant(nextEffect !== null, 'Should be working on an effect.');
2067-
captureCommitPhaseError(nextEffect, nextEffect.return, error);
2066+
captureCommitPhaseError(nextEffect, error);
20682067
nextEffect = nextEffect.nextEffect;
20692068
}
20702069
}
@@ -2091,15 +2090,15 @@ function commitRootImpl(root, renderPriorityLevel) {
20912090
if (hasCaughtError()) {
20922091
invariant(nextEffect !== null, 'Should be working on an effect.');
20932092
const error = clearCaughtError();
2094-
captureCommitPhaseError(nextEffect, nextEffect.return, error);
2093+
captureCommitPhaseError(nextEffect, error);
20952094
nextEffect = nextEffect.nextEffect;
20962095
}
20972096
} else {
20982097
try {
20992098
commitLayoutEffects(root, lanes);
21002099
} catch (error) {
21012100
invariant(nextEffect !== null, 'Should be working on an effect.');
2102-
captureCommitPhaseError(nextEffect, nextEffect.return, error);
2101+
captureCommitPhaseError(nextEffect, error);
21032102
nextEffect = nextEffect.nextEffect;
21042103
}
21052104
}
@@ -2373,12 +2372,7 @@ function commitMutationEffects(
23732372
break;
23742373
}
23752374
case Deletion: {
2376-
commitDeletion(
2377-
root,
2378-
nextEffect,
2379-
nextEffect.return,
2380-
renderPriorityLevel,
2381-
);
2375+
commitDeletion(root, nextEffect, renderPriorityLevel);
23822376
break;
23832377
}
23842378
}
@@ -2589,7 +2583,7 @@ function flushPassiveEffectsImpl() {
25892583
if (hasCaughtError()) {
25902584
invariant(fiber !== null, 'Should be working on an effect.');
25912585
const error = clearCaughtError();
2592-
captureCommitPhaseError(fiber, fiber.return, error);
2586+
captureCommitPhaseError(fiber, error);
25932587
}
25942588
resetCurrentDebugFiberInDEV();
25952589
} else {
@@ -2610,7 +2604,7 @@ function flushPassiveEffectsImpl() {
26102604
}
26112605
} catch (error) {
26122606
invariant(fiber !== null, 'Should be working on an effect.');
2613-
captureCommitPhaseError(fiber, fiber.return, error);
2607+
captureCommitPhaseError(fiber, error);
26142608
}
26152609
}
26162610
}
@@ -2637,7 +2631,7 @@ function flushPassiveEffectsImpl() {
26372631
if (hasCaughtError()) {
26382632
invariant(fiber !== null, 'Should be working on an effect.');
26392633
const error = clearCaughtError();
2640-
captureCommitPhaseError(fiber, fiber.return, error);
2634+
captureCommitPhaseError(fiber, error);
26412635
}
26422636
resetCurrentDebugFiberInDEV();
26432637
} else {
@@ -2659,7 +2653,7 @@ function flushPassiveEffectsImpl() {
26592653
}
26602654
} catch (error) {
26612655
invariant(fiber !== null, 'Should be working on an effect.');
2662-
captureCommitPhaseError(fiber, fiber.return, error);
2656+
captureCommitPhaseError(fiber, error);
26632657
}
26642658
}
26652659
}
@@ -2758,24 +2752,15 @@ function captureCommitPhaseErrorOnRoot(
27582752
}
27592753
}
27602754

2761-
export function captureCommitPhaseError(
2762-
sourceFiber: Fiber,
2763-
nearestMountedAncestor: Fiber | null,
2764-
error: mixed,
2765-
) {
2755+
export function captureCommitPhaseError(sourceFiber: Fiber, error: mixed) {
27662756
if (sourceFiber.tag === HostRoot) {
27672757
// Error was thrown at the root. There is no parent, so the root
27682758
// itself should capture it.
27692759
captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error);
27702760
return;
27712761
}
27722762

2773-
let fiber = null;
2774-
if (skipUnmountedBoundaries) {
2775-
fiber = nearestMountedAncestor;
2776-
} else {
2777-
fiber = sourceFiber.return;
2778-
}
2763+
let fiber = sourceFiber.return;
27792764

27802765
while (fiber !== null) {
27812766
if (fiber.tag === HostRoot) {

0 commit comments

Comments
 (0)