Skip to content

Commit 7332e83

Browse files
committed
replace-fork
1 parent b9c3948 commit 7332e83

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed

packages/react-reconciler/src/ReactFiberThrow.old.js

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -288,22 +288,15 @@ function getNearestSuspenseBoundaryToCapture(returnFiber: Fiber) {
288288
return null;
289289
}
290290

291-
function markNearestSuspenseBoundaryShouldCapture(
291+
function markSuspenseBoundaryShouldCapture(
292+
suspenseBoundary: Fiber,
292293
returnFiber: Fiber,
293294
sourceFiber: Fiber,
294295
root: FiberRoot,
295296
rootRenderLanes: Lanes,
296297
): Fiber | null {
297-
const suspenseBoundary = getNearestSuspenseBoundaryToCapture(returnFiber);
298-
299-
if (!suspenseBoundary) {
300-
// Could not find a Suspense boundary capable of capturing.
301-
return null;
302-
}
303-
304298
// This marks a Suspense boundary so that when we're unwinding the stack,
305299
// it captures the suspended "exception" and does a second (fallback) pass.
306-
307300
if ((suspenseBoundary.mode & ConcurrentMode) === NoMode) {
308301
// Legacy Mode Suspense
309302
//
@@ -464,13 +457,15 @@ function throwException(
464457
}
465458

466459
// Schedule the nearest Suspense to re-render the timed out view.
467-
const suspenseBoundary = markNearestSuspenseBoundaryShouldCapture(
468-
returnFiber,
469-
sourceFiber,
470-
root,
471-
rootRenderLanes,
472-
);
460+
const suspenseBoundary = getNearestSuspenseBoundaryToCapture(returnFiber);
473461
if (suspenseBoundary !== null) {
462+
markSuspenseBoundaryShouldCapture(
463+
suspenseBoundary,
464+
returnFiber,
465+
sourceFiber,
466+
root,
467+
rootRenderLanes,
468+
);
474469
attachWakeableListeners(
475470
suspenseBoundary,
476471
root,
@@ -494,25 +489,23 @@ function throwException(
494489
// This is a regular error, not a Suspense wakeable.
495490
if (getIsHydrating() && sourceFiber.mode & ConcurrentMode) {
496491
const suspenseBoundary = getNearestSuspenseBoundaryToCapture(returnFiber);
497-
const hasShouldCapture =
498-
suspenseBoundary !== null &&
499-
(suspenseBoundary.flags & ShouldCapture) !== NoFlags;
500492
// If the error was thrown during hydration, we may be able to recover by
501493
// discarding the dehydrated content and switching to a client render.
502494
// Instead of surfacing the error, find the nearest Suspense boundary
503495
// and render it again without hydration.
504-
markNearestSuspenseBoundaryShouldCapture(
505-
returnFiber,
506-
sourceFiber,
507-
root,
508-
rootRenderLanes,
509-
);
510496
if (suspenseBoundary !== null) {
511-
if (!hasShouldCapture) {
497+
if ((suspenseBoundary.flags & ShouldCapture) === NoFlags) {
512498
// Set a flag to indicate that we should try rendering the normal
513499
// children again, not the fallback.
514500
suspenseBoundary.flags |= ForceClientRender;
515501
}
502+
markSuspenseBoundaryShouldCapture(
503+
suspenseBoundary,
504+
returnFiber,
505+
sourceFiber,
506+
root,
507+
rootRenderLanes,
508+
);
516509
return;
517510
}
518511
} else {

0 commit comments

Comments
 (0)