throwException() — react Function Reference
Architecture documentation for the throwException() function in ReactFiberThrow.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD f933a08e_fb14_205d_b7b1_ce3073b61e36["throwException()"] 2945bdb1_d075_d792_a028_13eee518c9d4["ReactFiberThrow.js"] f933a08e_fb14_205d_b7b1_ce3073b61e36 -->|defined in| 2945bdb1_d075_d792_a028_13eee518c9d4 193cd750_beab_a60e_f635_6d131342856b["resetSuspendedComponent()"] f933a08e_fb14_205d_b7b1_ce3073b61e36 -->|calls| 193cd750_beab_a60e_f635_6d131342856b dae8f65a_04a5_194b_7c97_c4819e519207["getIsHydrating()"] f933a08e_fb14_205d_b7b1_ce3073b61e36 -->|calls| dae8f65a_04a5_194b_7c97_c4819e519207 67bfe1e3_b0b0_4dd1_39ce_20d1f2654287["markDidThrowWhileHydratingDEV()"] f933a08e_fb14_205d_b7b1_ce3073b61e36 -->|calls| 67bfe1e3_b0b0_4dd1_39ce_20d1f2654287 d14085e0_bbf9_ad5f_a4fd_14245c8f1b95["markSuspenseBoundaryShouldCapture()"] f933a08e_fb14_205d_b7b1_ce3073b61e36 -->|calls| d14085e0_bbf9_ad5f_a4fd_14245c8f1b95 ce664b89_0abe_3980_f572_e5b8149834de["createRootErrorUpdate()"] f933a08e_fb14_205d_b7b1_ce3073b61e36 -->|calls| ce664b89_0abe_3980_f572_e5b8149834de e0f62937_28bc_03b3_0af1_2dbfbdc7f4ec["createClassErrorUpdate()"] f933a08e_fb14_205d_b7b1_ce3073b61e36 -->|calls| e0f62937_28bc_03b3_0af1_2dbfbdc7f4ec e7ca53d8_6696_2eb1_6326_4df1eb1236b0["initializeClassErrorUpdate()"] f933a08e_fb14_205d_b7b1_ce3073b61e36 -->|calls| e7ca53d8_6696_2eb1_6326_4df1eb1236b0 style f933a08e_fb14_205d_b7b1_ce3073b61e36 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-reconciler/src/ReactFiberThrow.js lines 364–705
function throwException(
root: FiberRoot,
returnFiber: Fiber | null,
sourceFiber: Fiber,
value: mixed,
rootRenderLanes: Lanes,
): boolean {
// The source fiber did not complete.
sourceFiber.flags |= Incomplete;
if (enableUpdaterTracking) {
if (isDevToolsPresent) {
// If we have pending work still, restore the original updaters
restorePendingUpdaters(root, rootRenderLanes);
}
}
if (value !== null && typeof value === 'object') {
if (typeof value.then === 'function') {
// This is a wakeable. The component suspended.
const wakeable: Wakeable = (value: any);
resetSuspendedComponent(sourceFiber, rootRenderLanes);
if (__DEV__) {
if (
getIsHydrating() &&
(disableLegacyMode || sourceFiber.mode & ConcurrentMode)
) {
markDidThrowWhileHydratingDEV();
}
}
// Mark the nearest Suspense boundary to switch to rendering a fallback.
const suspenseBoundary = getSuspenseHandler();
if (suspenseBoundary !== null) {
switch (suspenseBoundary.tag) {
case ActivityComponent:
case SuspenseComponent:
case SuspenseListComponent: {
// If this suspense/activity boundary is not already showing a fallback, mark
// the in-progress render as suspended. We try to perform this logic
// as soon as soon as possible during the render phase, so the work
// loop can know things like whether it's OK to switch to other tasks,
// or whether it can wait for data to resolve before continuing.
// TODO: Most of these checks are already performed when entering a
// Suspense boundary. We should track the information on the stack so
// we don't have to recompute it on demand. This would also allow us
// to unify with `use` which needs to perform this logic even sooner,
// before `throwException` is called.
if (disableLegacyMode || sourceFiber.mode & ConcurrentMode) {
if (getShellBoundary() === null) {
// Suspended in the "shell" of the app. This is an undesirable
// loading state. We should avoid committing this tree.
renderDidSuspendDelayIfPossible();
} else {
// If we suspended deeper than the shell, we don't need to delay
// the commmit. However, we still call renderDidSuspend if this is
// a new boundary, to tell the work loop that a new fallback has
// appeared during this render.
// TODO: Theoretically we should be able to delete this branch.
// It's currently used for two things: 1) to throttle the
// appearance of successive loading states, and 2) in
// SuspenseList, to determine whether the children include any
// pending fallbacks. For 1, we should apply throttling to all
// retries, not just ones that render an additional fallback. For
// 2, we should check subtreeFlags instead. Then we can delete
// this branch.
const current = suspenseBoundary.alternate;
if (current === null) {
renderDidSuspend();
}
}
}
suspenseBoundary.flags &= ~ForceClientRender;
markSuspenseBoundaryShouldCapture(
suspenseBoundary,
returnFiber,
sourceFiber,
root,
rootRenderLanes,
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does throwException() do?
throwException() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberThrow.js.
Where is throwException() defined?
throwException() is defined in packages/react-reconciler/src/ReactFiberThrow.js at line 364.
What does throwException() call?
throwException() calls 7 function(s): createClassErrorUpdate, createRootErrorUpdate, getIsHydrating, initializeClassErrorUpdate, markDidThrowWhileHydratingDEV, markSuspenseBoundaryShouldCapture, resetSuspendedComponent.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free