Home / Function/ pushPrimaryTreeSuspenseHandler() — react Function Reference

pushPrimaryTreeSuspenseHandler() — react Function Reference

Architecture documentation for the pushPrimaryTreeSuspenseHandler() function in ReactFiberSuspenseContext.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  b647f646_ee62_5db9_2e55_81bfe0bcdd6c["pushPrimaryTreeSuspenseHandler()"]
  be9c7dd4_0030_1768_3ad3_f5acdbd08eef["ReactFiberSuspenseContext.js"]
  b647f646_ee62_5db9_2e55_81bfe0bcdd6c -->|defined in| be9c7dd4_0030_1768_3ad3_f5acdbd08eef
  f4acdab6_f680_af63_8940_0259a68c2f48["updateSuspenseComponent()"]
  f4acdab6_f680_af63_8940_0259a68c2f48 -->|calls| b647f646_ee62_5db9_2e55_81bfe0bcdd6c
  a8a1881a_9da1_7942_71cd_b9ab16efd50c["updateDehydratedSuspenseComponent()"]
  a8a1881a_9da1_7942_71cd_b9ab16efd50c -->|calls| b647f646_ee62_5db9_2e55_81bfe0bcdd6c
  7a74d7c7_a60b_d855_4210_5ede9b35da95["setDefaultShallowSuspenseListContext()"]
  b647f646_ee62_5db9_2e55_81bfe0bcdd6c -->|calls| 7a74d7c7_a60b_d855_4210_5ede9b35da95
  912a4546_c9a8_68b1_2d25_c20e5ab573cb["isCurrentTreeHidden()"]
  b647f646_ee62_5db9_2e55_81bfe0bcdd6c -->|calls| 912a4546_c9a8_68b1_2d25_c20e5ab573cb
  style b647f646_ee62_5db9_2e55_81bfe0bcdd6c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-reconciler/src/ReactFiberSuspenseContext.js lines 43–101

export function pushPrimaryTreeSuspenseHandler(handler: Fiber): void {
  // TODO: Pass as argument
  const current = handler.alternate;
  const props: SuspenseProps = handler.pendingProps;

  // Shallow Suspense context fields, like ForceSuspenseFallback, should only be
  // propagated a single level. For example, when ForceSuspenseFallback is set,
  // it should only force the nearest Suspense boundary into fallback mode.
  push(
    suspenseStackCursor,
    setDefaultShallowSuspenseListContext(suspenseStackCursor.current),
    handler,
  );

  // Experimental feature: Some Suspense boundaries are marked as having an
  // undesirable fallback state. These have special behavior where we only
  // activate the fallback if there's no other boundary on the stack that we can
  // use instead.
  if (
    enableSuspenseAvoidThisFallback &&
    props.unstable_avoidThisFallback === true &&
    // If an avoided boundary is already visible, it behaves identically to
    // a regular Suspense boundary.
    (current === null || isCurrentTreeHidden())
  ) {
    if (shellBoundary === null) {
      // We're rendering in the shell. There's no parent Suspense boundary that
      // can provide a desirable fallback state. We'll use this boundary.
      push(suspenseHandlerStackCursor, handler, handler);

      // However, because this is not a desirable fallback, the children are
      // still considered part of the shell. So we intentionally don't assign
      // to `shellBoundary`.
    } else {
      // There's already a parent Suspense boundary that can provide a desirable
      // fallback state. Prefer that one.
      const handlerOnStack = suspenseHandlerStackCursor.current;
      push(suspenseHandlerStackCursor, handlerOnStack, handler);
    }
    return;
  }

  // TODO: If the parent Suspense handler already suspended, there's no reason
  // to push a nested Suspense handler, because it will get replaced by the
  // outer fallback, anyway. Consider this as a future optimization.
  push(suspenseHandlerStackCursor, handler, handler);
  if (shellBoundary === null) {
    if (current === null || isCurrentTreeHidden()) {
      // This boundary is not visible in the current UI.
      shellBoundary = handler;
    } else {
      const prevState: SuspenseState = current.memoizedState;
      if (prevState !== null) {
        // This boundary is showing a fallback in the current UI.
        shellBoundary = handler;
      }
    }
  }
}

Domain

Subdomains

Frequently Asked Questions

What does pushPrimaryTreeSuspenseHandler() do?
pushPrimaryTreeSuspenseHandler() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberSuspenseContext.js.
Where is pushPrimaryTreeSuspenseHandler() defined?
pushPrimaryTreeSuspenseHandler() is defined in packages/react-reconciler/src/ReactFiberSuspenseContext.js at line 43.
What does pushPrimaryTreeSuspenseHandler() call?
pushPrimaryTreeSuspenseHandler() calls 2 function(s): isCurrentTreeHidden, setDefaultShallowSuspenseListContext.
What calls pushPrimaryTreeSuspenseHandler()?
pushPrimaryTreeSuspenseHandler() is called by 2 function(s): updateDehydratedSuspenseComponent, updateSuspenseComponent.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free