Home / Function/ updateDehydratedSuspenseComponent() — react Function Reference

updateDehydratedSuspenseComponent() — react Function Reference

Architecture documentation for the updateDehydratedSuspenseComponent() function in ReactFiberBeginWork.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  a8a1881a_9da1_7942_71cd_b9ab16efd50c["updateDehydratedSuspenseComponent()"]
  0be70812_cc0c_b210_f84f_8e61dd5f831c["ReactFiberBeginWork.js"]
  a8a1881a_9da1_7942_71cd_b9ab16efd50c -->|defined in| 0be70812_cc0c_b210_f84f_8e61dd5f831c
  f4acdab6_f680_af63_8940_0259a68c2f48["updateSuspenseComponent()"]
  f4acdab6_f680_af63_8940_0259a68c2f48 -->|calls| a8a1881a_9da1_7942_71cd_b9ab16efd50c
  b647f646_ee62_5db9_2e55_81bfe0bcdd6c["pushPrimaryTreeSuspenseHandler()"]
  a8a1881a_9da1_7942_71cd_b9ab16efd50c -->|calls| b647f646_ee62_5db9_2e55_81bfe0bcdd6c
  a4082647_57a0_a4c2_d6f0_4e94beb28e99["warnIfHydrating()"]
  a8a1881a_9da1_7942_71cd_b9ab16efd50c -->|calls| a4082647_57a0_a4c2_d6f0_4e94beb28e99
  be4589a2_090c_02a1_d89c_154f9573acc3["retrySuspenseComponentWithoutHydrating()"]
  a8a1881a_9da1_7942_71cd_b9ab16efd50c -->|calls| be4589a2_090c_02a1_d89c_154f9573acc3
  fd04db56_fd9e_22dc_0306_714074ba0169["reenterHydrationStateFromDehydratedSuspenseInstance()"]
  a8a1881a_9da1_7942_71cd_b9ab16efd50c -->|calls| fd04db56_fd9e_22dc_0306_714074ba0169
  80f1c189_9114_4d52_32dc_752c9920a1de["mountSuspensePrimaryChildren()"]
  a8a1881a_9da1_7942_71cd_b9ab16efd50c -->|calls| 80f1c189_9114_4d52_32dc_752c9920a1de
  0792b4b9_d145_0f54_f5dc_1c2c75771d59["pushFallbackTreeSuspenseHandler()"]
  a8a1881a_9da1_7942_71cd_b9ab16efd50c -->|calls| 0792b4b9_d145_0f54_f5dc_1c2c75771d59
  d187177d_7fab_220f_9207_e4af82b37796["mountSuspenseFallbackAfterRetryWithoutHydrating()"]
  a8a1881a_9da1_7942_71cd_b9ab16efd50c -->|calls| d187177d_7fab_220f_9207_e4af82b37796
  73f20134_454b_c241_2ca5_e1c276ddc31d["mountSuspenseOffscreenState()"]
  a8a1881a_9da1_7942_71cd_b9ab16efd50c -->|calls| 73f20134_454b_c241_2ca5_e1c276ddc31d
  a9bd5488_92fb_77d0_d235_59865a308ccf["getRemainingWorkInPrimaryTree()"]
  a8a1881a_9da1_7942_71cd_b9ab16efd50c -->|calls| a9bd5488_92fb_77d0_d235_59865a308ccf
  219a3239_d833_17eb_948a_bef7724b5517["bailoutOffscreenComponent()"]
  a8a1881a_9da1_7942_71cd_b9ab16efd50c -->|calls| 219a3239_d833_17eb_948a_bef7724b5517
  style a8a1881a_9da1_7942_71cd_b9ab16efd50c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-reconciler/src/ReactFiberBeginWork.js lines 2934–3159

function updateDehydratedSuspenseComponent(
  current: Fiber,
  workInProgress: Fiber,
  didSuspend: boolean,
  didPrimaryChildrenDefer: boolean,
  nextProps: SuspenseProps,
  suspenseInstance: SuspenseInstance,
  suspenseState: SuspenseState,
  renderLanes: Lanes,
): null | Fiber {
  if (!didSuspend) {
    // This is the first render pass. Attempt to hydrate.
    pushPrimaryTreeSuspenseHandler(workInProgress);

    // We should never be hydrating at this point because it is the first pass,
    // but after we've already committed once.
    warnIfHydrating();

    if (includesSomeLane(renderLanes, (OffscreenLane: Lane))) {
      // If we're rendering Offscreen and we're entering the activity then it's possible
      // that the only reason we rendered was because this boundary left work. Provide
      // it as a cause if another one doesn't already exist.
      markRenderDerivedCause(workInProgress);
    }

    if (isSuspenseInstanceFallback(suspenseInstance)) {
      // This boundary is in a permanent fallback state. In this case, we'll never
      // get an update and we'll never be able to hydrate the final content. Let's just try the
      // client side render instead.
      let digest: ?string;
      let message;
      let stack = null;
      let componentStack = null;
      if (__DEV__) {
        ({digest, message, stack, componentStack} =
          getSuspenseInstanceFallbackErrorDetails(suspenseInstance));
      } else {
        ({digest} = getSuspenseInstanceFallbackErrorDetails(suspenseInstance));
      }

      let error: Error;
      if (__DEV__ && message) {
        // eslint-disable-next-line react-internal/prod-error-codes
        error = new Error(message);
      } else {
        error = new Error(
          'The server could not finish this Suspense boundary, likely ' +
            'due to an error during server rendering. ' +
            'Switched to client rendering.',
        );
      }
      // Replace the stack with the server stack
      error.stack = (__DEV__ && stack) || '';
      (error: any).digest = digest;
      const capturedValue = createCapturedValueFromError(
        error,
        componentStack === undefined ? null : componentStack,
      );
      queueHydrationError(capturedValue);
      return retrySuspenseComponentWithoutHydrating(
        current,
        workInProgress,
        renderLanes,
      );
    }

    if (
      // TODO: Factoring is a little weird, since we check this right below, too.
      !didReceiveUpdate
    ) {
      // We need to check if any children have context before we decide to bail
      // out, so propagate the changes now.
      lazilyPropagateParentContextChanges(current, workInProgress, renderLanes);
    }

    // We use lanes to indicate that a child might depend on context, so if
    // any context has changed, we need to treat is as if the input might have changed.
    const hasContextChanged = includesSomeLane(renderLanes, current.childLanes);
    if (didReceiveUpdate || hasContextChanged) {
      // This boundary has changed since the first render. This means that we are now unable to
      // hydrate it. We might still be able to hydrate it using a higher priority lane.

Domain

Subdomains

Frequently Asked Questions

What does updateDehydratedSuspenseComponent() do?
updateDehydratedSuspenseComponent() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberBeginWork.js.
Where is updateDehydratedSuspenseComponent() defined?
updateDehydratedSuspenseComponent() is defined in packages/react-reconciler/src/ReactFiberBeginWork.js at line 2934.
What does updateDehydratedSuspenseComponent() call?
updateDehydratedSuspenseComponent() calls 10 function(s): bailoutOffscreenComponent, getRemainingWorkInPrimaryTree, mountSuspenseFallbackAfterRetryWithoutHydrating, mountSuspenseOffscreenState, mountSuspensePrimaryChildren, pushFallbackTreeSuspenseHandler, pushPrimaryTreeSuspenseHandler, reenterHydrationStateFromDehydratedSuspenseInstance, and 2 more.
What calls updateDehydratedSuspenseComponent()?
updateDehydratedSuspenseComponent() is called by 1 function(s): updateSuspenseComponent.

Analyze Your Own Codebase

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

Try Supermodel Free