GeezerVison is showing github.com — Removed skip-error-boundaries modifications from old fork (#19961) · react/react@44d39c4
File treeExpand file treeCollapse file tree Open diff view settings packages/react-reconciler/src
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberCommitWork.old.js +22-73Lines changed: 22 additions & 73 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -153,11 +153,7 @@ const callComponentWillUnmountWithTimer = function(current, instance) { | 153 | 153 | }; | 154 | 154 |
| 155 | 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) { | 161 | 157 | if (__DEV__) { | 162 | 158 | invokeGuardedCallback( | 163 | 159 | null, | @@ -168,32 +164,32 @@ function safelyCallComponentWillUnmount( | 168 | 164 | ); | 169 | 165 | if (hasCaughtError()) { | 170 | 166 | const unmountError = clearCaughtError(); | 171 | | - captureCommitPhaseError(current, nearestMountedAncestor, unmountError); | | 167 | + captureCommitPhaseError(current, unmountError); | 172 | 168 | } | 173 | 169 | } else { | 174 | 170 | try { | 175 | 171 | callComponentWillUnmountWithTimer(current, instance); | 176 | 172 | } catch (unmountError) { | 177 | | - captureCommitPhaseError(current, nearestMountedAncestor, unmountError); | | 173 | + captureCommitPhaseError(current, unmountError); | 178 | 174 | } | 179 | 175 | } | 180 | 176 | } | 181 | 177 |
| 182 | | -function safelyDetachRef(current: Fiber, nearestMountedAncestor: Fiber | null) { | | 178 | +function safelyDetachRef(current: Fiber) { | 183 | 179 | const ref = current.ref; | 184 | 180 | if (ref !== null) { | 185 | 181 | if (typeof ref === 'function') { | 186 | 182 | if (__DEV__) { | 187 | 183 | invokeGuardedCallback(null, ref, null, null); | 188 | 184 | if (hasCaughtError()) { | 189 | 185 | const refError = clearCaughtError(); | 190 | | - captureCommitPhaseError(current, nearestMountedAncestor, refError); | | 186 | + captureCommitPhaseError(current, refError); | 191 | 187 | } | 192 | 188 | } else { | 193 | 189 | try { | 194 | 190 | ref(null); | 195 | 191 | } catch (refError) { | 196 | | - captureCommitPhaseError(current, nearestMountedAncestor, refError); | | 192 | + captureCommitPhaseError(current, refError); | 197 | 193 | } | 198 | 194 | } | 199 | 195 | } else { | @@ -202,22 +198,18 @@ function safelyDetachRef(current: Fiber, nearestMountedAncestor: Fiber | null) { | 202 | 198 | } | 203 | 199 | } | 204 | 200 |
| 205 | | -function safelyCallDestroy( | 206 | | - current: Fiber, | 207 | | - nearestMountedAncestor: Fiber | null, | 208 | | - destroy: () => void, | 209 | | -) { | | 201 | +function safelyCallDestroy(current: Fiber, destroy: () => void) { | 210 | 202 | if (__DEV__) { | 211 | 203 | invokeGuardedCallback(null, destroy, null); | 212 | 204 | if (hasCaughtError()) { | 213 | 205 | const error = clearCaughtError(); | 214 | | - captureCommitPhaseError(current, nearestMountedAncestor, error); | | 206 | + captureCommitPhaseError(current, error); | 215 | 207 | } | 216 | 208 | } else { | 217 | 209 | try { | 218 | 210 | destroy(); | 219 | 211 | } catch (error) { | 220 | | - captureCommitPhaseError(current, nearestMountedAncestor, error); | | 212 | + captureCommitPhaseError(current, error); | 221 | 213 | } | 222 | 214 | } | 223 | 215 | } | @@ -874,7 +866,6 @@ function commitDetachRef(current: Fiber) { | 874 | 866 | function commitUnmount( | 875 | 867 | finishedRoot: FiberRoot, | 876 | 868 | current: Fiber, | 877 | | - nearestMountedAncestor: Fiber | null, | 878 | 869 | renderPriorityLevel: ReactPriorityLevel, | 879 | 870 | ): void { | 880 | 871 | onCommitUnmount(current); | @@ -904,10 +895,10 @@ function commitUnmount( | 904 | 895 | current.mode & ProfileMode | 905 | 896 | ) { | 906 | 897 | startLayoutEffectTimer(); | 907 | | - safelyCallDestroy(current, nearestMountedAncestor, destroy); | | 898 | + safelyCallDestroy(current, destroy); | 908 | 899 | recordLayoutEffectDuration(current); | 909 | 900 | } else { | 910 | | - safelyCallDestroy(current, nearestMountedAncestor, destroy); | | 901 | + safelyCallDestroy(current, destroy); | 911 | 902 | } | 912 | 903 | } | 913 | 904 | } | @@ -918,32 +909,23 @@ function commitUnmount( | 918 | 909 | return; | 919 | 910 | } | 920 | 911 | case ClassComponent: { | 921 | | - safelyDetachRef(current, nearestMountedAncestor); | | 912 | + safelyDetachRef(current); | 922 | 913 | const instance = current.stateNode; | 923 | 914 | if (typeof instance.componentWillUnmount === 'function') { | 924 | | - safelyCallComponentWillUnmount( | 925 | | - current, | 926 | | - instance, | 927 | | - nearestMountedAncestor, | 928 | | - ); | | 915 | + safelyCallComponentWillUnmount(current, instance); | 929 | 916 | } | 930 | 917 | return; | 931 | 918 | } | 932 | 919 | case HostComponent: { | 933 | | - safelyDetachRef(current, nearestMountedAncestor); | | 920 | + safelyDetachRef(current); | 934 | 921 | return; | 935 | 922 | } | 936 | 923 | case HostPortal: { | 937 | 924 | // TODO: this is recursive. | 938 | 925 | // We are also not using this parent because | 939 | 926 | // the portal will get pushed immediately. | 940 | 927 | if (supportsMutation) { | 941 | | - unmountHostComponents( | 942 | | - finishedRoot, | 943 | | - current, | 944 | | - nearestMountedAncestor, | 945 | | - renderPriorityLevel, | 946 | | - ); | | 928 | + unmountHostComponents(finishedRoot, current, renderPriorityLevel); | 947 | 929 | } else if (supportsPersistence) { | 948 | 930 | emptyPortalContainer(current); | 949 | 931 | } | @@ -973,7 +955,7 @@ function commitUnmount( | 973 | 955 | } | 974 | 956 | case ScopeComponent: { | 975 | 957 | if (enableScopeAPI) { | 976 | | - safelyDetachRef(current, nearestMountedAncestor); | | 958 | + safelyDetachRef(current); | 977 | 959 | } | 978 | 960 | return; | 979 | 961 | } | @@ -983,7 +965,6 @@ function commitUnmount( | 983 | 965 | function commitNestedUnmounts( | 984 | 966 | finishedRoot: FiberRoot, | 985 | 967 | root: Fiber, | 986 | | - nearestMountedAncestor: Fiber | null, | 987 | 968 | renderPriorityLevel: ReactPriorityLevel, | 988 | 969 | ): void { | 989 | 970 | // While we're inside a removed host node we don't want to call | @@ -993,12 +974,7 @@ function commitNestedUnmounts( | 993 | 974 | // we do an inner loop while we're still inside the host node. | 994 | 975 | let node: Fiber = root; | 995 | 976 | while (true) { | 996 | | - commitUnmount( | 997 | | - finishedRoot, | 998 | | - node, | 999 | | - nearestMountedAncestor, | 1000 | | - renderPriorityLevel, | 1001 | | - ); | | 977 | + commitUnmount(finishedRoot, node, renderPriorityLevel); | 1002 | 978 | // Visit children because they may contain more composite or host nodes. | 1003 | 979 | // Skip portals because commitUnmount() currently visits them recursively. | 1004 | 980 | if ( | @@ -1289,7 +1265,6 @@ function insertOrAppendPlacementNode( | 1289 | 1265 | function unmountHostComponents( | 1290 | 1266 | finishedRoot: FiberRoot, | 1291 | 1267 | current: Fiber, | 1292 | | - nearestMountedAncestor: Fiber | null, | 1293 | 1268 | renderPriorityLevel: ReactPriorityLevel, | 1294 | 1269 | ): void { | 1295 | 1270 | // We only have the top Fiber that was deleted but we need to recurse down its | @@ -1339,12 +1314,7 @@ function unmountHostComponents( | 1339 | 1314 | } | 1340 | 1315 |
| 1341 | 1316 | if (node.tag === HostComponent || node.tag === HostText) { | 1342 | | - commitNestedUnmounts( | 1343 | | - finishedRoot, | 1344 | | - node, | 1345 | | - nearestMountedAncestor, | 1346 | | - renderPriorityLevel, | 1347 | | - ); | | 1317 | + commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); | 1348 | 1318 | // After all the children have unmounted, it is now safe to remove the | 1349 | 1319 | // node from the tree. | 1350 | 1320 | if (currentParentIsContainer) { | @@ -1361,12 +1331,7 @@ function unmountHostComponents( | 1361 | 1331 | // Don't visit children because we already visited them. | 1362 | 1332 | } else if (enableFundamentalAPI && node.tag === FundamentalComponent) { | 1363 | 1333 | const fundamentalNode = node.stateNode.instance; | 1364 | | - commitNestedUnmounts( | 1365 | | - finishedRoot, | 1366 | | - node, | 1367 | | - nearestMountedAncestor, | 1368 | | - renderPriorityLevel, | 1369 | | - ); | | 1334 | + commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); | 1370 | 1335 | // After all the children have unmounted, it is now safe to remove the | 1371 | 1336 | // node from the tree. | 1372 | 1337 | if (currentParentIsContainer) { | @@ -1418,12 +1383,7 @@ function unmountHostComponents( | 1418 | 1383 | continue; | 1419 | 1384 | } | 1420 | 1385 | } else { | 1421 | | - commitUnmount( | 1422 | | - finishedRoot, | 1423 | | - node, | 1424 | | - nearestMountedAncestor, | 1425 | | - renderPriorityLevel, | 1426 | | - ); | | 1386 | + commitUnmount(finishedRoot, node, renderPriorityLevel); | 1427 | 1387 | // Visit children because we may find more host components below. | 1428 | 1388 | if (node.child !== null) { | 1429 | 1389 | node.child.return = node; | @@ -1453,26 +1413,15 @@ function unmountHostComponents( | 1453 | 1413 | function commitDeletion( | 1454 | 1414 | finishedRoot: FiberRoot, | 1455 | 1415 | current: Fiber, | 1456 | | - nearestMountedAncestor: Fiber | null, | 1457 | 1416 | renderPriorityLevel: ReactPriorityLevel, | 1458 | 1417 | ): void { | 1459 | 1418 | if (supportsMutation) { | 1460 | 1419 | // Recursively delete all host nodes from the parent. | 1461 | 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); | 1468 | 1422 | } else { | 1469 | 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); | 1476 | 1425 | } | 1477 | 1426 | const alternate = current.alternate; | 1478 | 1427 | detachFiberMutation(current); | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberWorkLoop.old.js +13-28Lines changed: 13 additions & 28 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -29,7 +29,6 @@ import { | 29 | 29 | enableDebugTracing, | 30 | 30 | enableSchedulingProfiler, | 31 | 31 | enableScopeAPI, | 32 | | - skipUnmountedBoundaries, | 33 | 32 | } from 'shared/ReactFeatureFlags'; | 34 | 33 | import ReactSharedInternals from 'shared/ReactSharedInternals'; | 35 | 34 | import invariant from 'shared/invariant'; | @@ -2019,15 +2018,15 @@ function commitRootImpl(root, renderPriorityLevel) { | 2019 | 2018 | if (hasCaughtError()) { | 2020 | 2019 | invariant(nextEffect !== null, 'Should be working on an effect.'); | 2021 | 2020 | const error = clearCaughtError(); | 2022 | | - captureCommitPhaseError(nextEffect, nextEffect.return, error); | | 2021 | + captureCommitPhaseError(nextEffect, error); | 2023 | 2022 | nextEffect = nextEffect.nextEffect; | 2024 | 2023 | } | 2025 | 2024 | } else { | 2026 | 2025 | try { | 2027 | 2026 | commitBeforeMutationEffects(); | 2028 | 2027 | } catch (error) { | 2029 | 2028 | invariant(nextEffect !== null, 'Should be working on an effect.'); | 2030 | | - captureCommitPhaseError(nextEffect, nextEffect.return, error); | | 2029 | + captureCommitPhaseError(nextEffect, error); | 2031 | 2030 | nextEffect = nextEffect.nextEffect; | 2032 | 2031 | } | 2033 | 2032 | } | @@ -2056,15 +2055,15 @@ function commitRootImpl(root, renderPriorityLevel) { | 2056 | 2055 | if (hasCaughtError()) { | 2057 | 2056 | invariant(nextEffect !== null, 'Should be working on an effect.'); | 2058 | 2057 | const error = clearCaughtError(); | 2059 | | - captureCommitPhaseError(nextEffect, nextEffect.return, error); | | 2058 | + captureCommitPhaseError(nextEffect, error); | 2060 | 2059 | nextEffect = nextEffect.nextEffect; | 2061 | 2060 | } | 2062 | 2061 | } else { | 2063 | 2062 | try { | 2064 | 2063 | commitMutationEffects(root, renderPriorityLevel); | 2065 | 2064 | } catch (error) { | 2066 | 2065 | invariant(nextEffect !== null, 'Should be working on an effect.'); | 2067 | | - captureCommitPhaseError(nextEffect, nextEffect.return, error); | | 2066 | + captureCommitPhaseError(nextEffect, error); | 2068 | 2067 | nextEffect = nextEffect.nextEffect; | 2069 | 2068 | } | 2070 | 2069 | } | @@ -2091,15 +2090,15 @@ function commitRootImpl(root, renderPriorityLevel) { | 2091 | 2090 | if (hasCaughtError()) { | 2092 | 2091 | invariant(nextEffect !== null, 'Should be working on an effect.'); | 2093 | 2092 | const error = clearCaughtError(); | 2094 | | - captureCommitPhaseError(nextEffect, nextEffect.return, error); | | 2093 | + captureCommitPhaseError(nextEffect, error); | 2095 | 2094 | nextEffect = nextEffect.nextEffect; | 2096 | 2095 | } | 2097 | 2096 | } else { | 2098 | 2097 | try { | 2099 | 2098 | commitLayoutEffects(root, lanes); | 2100 | 2099 | } catch (error) { | 2101 | 2100 | invariant(nextEffect !== null, 'Should be working on an effect.'); | 2102 | | - captureCommitPhaseError(nextEffect, nextEffect.return, error); | | 2101 | + captureCommitPhaseError(nextEffect, error); | 2103 | 2102 | nextEffect = nextEffect.nextEffect; | 2104 | 2103 | } | 2105 | 2104 | } | @@ -2373,12 +2372,7 @@ function commitMutationEffects( | 2373 | 2372 | break; | 2374 | 2373 | } | 2375 | 2374 | case Deletion: { | 2376 | | - commitDeletion( | 2377 | | - root, | 2378 | | - nextEffect, | 2379 | | - nextEffect.return, | 2380 | | - renderPriorityLevel, | 2381 | | - ); | | 2375 | + commitDeletion(root, nextEffect, renderPriorityLevel); | 2382 | 2376 | break; | 2383 | 2377 | } | 2384 | 2378 | } | @@ -2589,7 +2583,7 @@ function flushPassiveEffectsImpl() { | 2589 | 2583 | if (hasCaughtError()) { | 2590 | 2584 | invariant(fiber !== null, 'Should be working on an effect.'); | 2591 | 2585 | const error = clearCaughtError(); | 2592 | | - captureCommitPhaseError(fiber, fiber.return, error); | | 2586 | + captureCommitPhaseError(fiber, error); | 2593 | 2587 | } | 2594 | 2588 | resetCurrentDebugFiberInDEV(); | 2595 | 2589 | } else { | @@ -2610,7 +2604,7 @@ function flushPassiveEffectsImpl() { | 2610 | 2604 | } | 2611 | 2605 | } catch (error) { | 2612 | 2606 | invariant(fiber !== null, 'Should be working on an effect.'); | 2613 | | - captureCommitPhaseError(fiber, fiber.return, error); | | 2607 | + captureCommitPhaseError(fiber, error); | 2614 | 2608 | } | 2615 | 2609 | } | 2616 | 2610 | } | @@ -2637,7 +2631,7 @@ function flushPassiveEffectsImpl() { | 2637 | 2631 | if (hasCaughtError()) { | 2638 | 2632 | invariant(fiber !== null, 'Should be working on an effect.'); | 2639 | 2633 | const error = clearCaughtError(); | 2640 | | - captureCommitPhaseError(fiber, fiber.return, error); | | 2634 | + captureCommitPhaseError(fiber, error); | 2641 | 2635 | } | 2642 | 2636 | resetCurrentDebugFiberInDEV(); | 2643 | 2637 | } else { | @@ -2659,7 +2653,7 @@ function flushPassiveEffectsImpl() { | 2659 | 2653 | } | 2660 | 2654 | } catch (error) { | 2661 | 2655 | invariant(fiber !== null, 'Should be working on an effect.'); | 2662 | | - captureCommitPhaseError(fiber, fiber.return, error); | | 2656 | + captureCommitPhaseError(fiber, error); | 2663 | 2657 | } | 2664 | 2658 | } | 2665 | 2659 | } | @@ -2758,24 +2752,15 @@ function captureCommitPhaseErrorOnRoot( | 2758 | 2752 | } | 2759 | 2753 | } | 2760 | 2754 |
| 2761 | | -export function captureCommitPhaseError( | 2762 | | - sourceFiber: Fiber, | 2763 | | - nearestMountedAncestor: Fiber | null, | 2764 | | - error: mixed, | 2765 | | -) { | | 2755 | +export function captureCommitPhaseError(sourceFiber: Fiber, error: mixed) { | 2766 | 2756 | if (sourceFiber.tag === HostRoot) { | 2767 | 2757 | // Error was thrown at the root. There is no parent, so the root | 2768 | 2758 | // itself should capture it. | 2769 | 2759 | captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); | 2770 | 2760 | return; | 2771 | 2761 | } | 2772 | 2762 |
| 2773 | | - let fiber = null; | 2774 | | - if (skipUnmountedBoundaries) { | 2775 | | - fiber = nearestMountedAncestor; | 2776 | | - } else { | 2777 | | - fiber = sourceFiber.return; | 2778 | | - } | | 2763 | + let fiber = sourceFiber.return; | 2779 | 2764 |
| 2780 | 2765 | while (fiber !== null) { | 2781 | 2766 | if (fiber.tag === HostRoot) { | |
|