markSuspenseBoundaryShouldCapture() — react Function Reference
Architecture documentation for the markSuspenseBoundaryShouldCapture() function in ReactFiberThrow.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD d14085e0_bbf9_ad5f_a4fd_14245c8f1b95["markSuspenseBoundaryShouldCapture()"] 2945bdb1_d075_d792_a028_13eee518c9d4["ReactFiberThrow.js"] d14085e0_bbf9_ad5f_a4fd_14245c8f1b95 -->|defined in| 2945bdb1_d075_d792_a028_13eee518c9d4 f933a08e_fb14_205d_b7b1_ce3073b61e36["throwException()"] f933a08e_fb14_205d_b7b1_ce3073b61e36 -->|calls| d14085e0_bbf9_ad5f_a4fd_14245c8f1b95 style d14085e0_bbf9_ad5f_a4fd_14245c8f1b95 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-reconciler/src/ReactFiberThrow.js lines 241–362
function markSuspenseBoundaryShouldCapture(
suspenseBoundary: Fiber,
returnFiber: Fiber | null,
sourceFiber: Fiber,
root: FiberRoot,
rootRenderLanes: Lanes,
): Fiber | null {
// This marks a Suspense boundary so that when we're unwinding the stack,
// it captures the suspended "exception" and does a second (fallback) pass.
if (
!disableLegacyMode &&
(suspenseBoundary.mode & ConcurrentMode) === NoMode
) {
// Legacy Mode Suspense
//
// If the boundary is in legacy mode, we should *not*
// suspend the commit. Pretend as if the suspended component rendered
// null and keep rendering. When the Suspense boundary completes,
// we'll do a second pass to render the fallback.
if (suspenseBoundary === returnFiber) {
// Special case where we suspended while reconciling the children of
// a Suspense boundary's inner Offscreen wrapper fiber. This happens
// when a React.lazy component is a direct child of a
// Suspense boundary.
//
// Suspense boundaries are implemented as multiple fibers, but they
// are a single conceptual unit. The legacy mode behavior where we
// pretend the suspended fiber committed as `null` won't work,
// because in this case the "suspended" fiber is the inner
// Offscreen wrapper.
//
// Because the contents of the boundary haven't started rendering
// yet (i.e. nothing in the tree has partially rendered) we can
// switch to the regular, concurrent mode behavior: mark the
// boundary with ShouldCapture and enter the unwind phase.
suspenseBoundary.flags |= ShouldCapture;
} else {
suspenseBoundary.flags |= DidCapture;
sourceFiber.flags |= ForceUpdateForLegacySuspense;
// We're going to commit this fiber even though it didn't complete.
// But we shouldn't call any lifecycle methods or callbacks. Remove
// all lifecycle effect tags.
sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete);
if (sourceFiber.tag === ClassComponent) {
const currentSourceFiber = sourceFiber.alternate;
if (currentSourceFiber === null) {
// This is a new mount. Change the tag so it's not mistaken for a
// completed class component. For example, we should not call
// componentWillUnmount if it is deleted.
sourceFiber.tag = IncompleteClassComponent;
} else {
// When we try rendering again, we should not reuse the current fiber,
// since it's known to be in an inconsistent state. Use a force update to
// prevent a bail out.
const update = createUpdate(SyncLane);
update.tag = ForceUpdate;
enqueueUpdate(sourceFiber, update, SyncLane);
}
} else if (sourceFiber.tag === FunctionComponent) {
const currentSourceFiber = sourceFiber.alternate;
if (currentSourceFiber === null) {
// This is a new mount. Change the tag so it's not mistaken for a
// completed function component.
sourceFiber.tag = IncompleteFunctionComponent;
}
}
// The source fiber did not complete. Mark it with Sync priority to
// indicate that it still has pending work.
sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane);
}
return suspenseBoundary;
}
// Confirmed that the boundary is in a concurrent mode tree. Continue
// with the normal suspend path.
//
// After this we'll use a set of heuristics to determine whether this
// render pass will run to completion or restart or "suspend" the commit.
// The actual logic for this is spread out in different places.
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does markSuspenseBoundaryShouldCapture() do?
markSuspenseBoundaryShouldCapture() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberThrow.js.
Where is markSuspenseBoundaryShouldCapture() defined?
markSuspenseBoundaryShouldCapture() is defined in packages/react-reconciler/src/ReactFiberThrow.js at line 241.
What calls markSuspenseBoundaryShouldCapture()?
markSuspenseBoundaryShouldCapture() is called by 1 function(s): throwException.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free