Home / Function/ completeDehydratedActivityBoundary() — react Function Reference

completeDehydratedActivityBoundary() — react Function Reference

Architecture documentation for the completeDehydratedActivityBoundary() function in ReactFiberCompleteWork.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  44c16661_4569_a3d1_aee6_5c634865dd4f["completeDehydratedActivityBoundary()"]
  6b05669d_2f09_63a5_e79f_0afc195f25a3["ReactFiberCompleteWork.js"]
  44c16661_4569_a3d1_aee6_5c634865dd4f -->|defined in| 6b05669d_2f09_63a5_e79f_0afc195f25a3
  0b8db832_87fd_e560_8aa8_e2b319c81626["completeWork()"]
  0b8db832_87fd_e560_8aa8_e2b319c81626 -->|calls| 44c16661_4569_a3d1_aee6_5c634865dd4f
  b741356a_b031_e7cd_ea5d_ed59f056748d["popHydrationState()"]
  44c16661_4569_a3d1_aee6_5c634865dd4f -->|calls| b741356a_b031_e7cd_ea5d_ed59f056748d
  d3a0fb0e_3856_9f07_c8bf_d7822a92f4b1["prepareToHydrateHostActivityInstance()"]
  44c16661_4569_a3d1_aee6_5c634865dd4f -->|calls| d3a0fb0e_3856_9f07_c8bf_d7822a92f4b1
  1a7e7cc1_6419_de9c_0611_6890ef404e66["bubbleProperties()"]
  44c16661_4569_a3d1_aee6_5c634865dd4f -->|calls| 1a7e7cc1_6419_de9c_0611_6890ef404e66
  87c1044e_4880_6c4c_bb78_f18f233bb260["resetHydrationState()"]
  44c16661_4569_a3d1_aee6_5c634865dd4f -->|calls| 87c1044e_4880_6c4c_bb78_f18f233bb260
  style 44c16661_4569_a3d1_aee6_5c634865dd4f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-reconciler/src/ReactFiberCompleteWork.js lines 904–984

function completeDehydratedActivityBoundary(
  current: Fiber | null,
  workInProgress: Fiber,
  nextState: ActivityState | null,
): boolean {
  const wasHydrated = popHydrationState(workInProgress);

  if (nextState !== null) {
    // We might be inside a hydration state the first time we're picking up this
    // Activity boundary, and also after we've reentered it for further hydration.
    if (current === null) {
      if (!wasHydrated) {
        throw new Error(
          'A dehydrated suspense component was completed without a hydrated node. ' +
            'This is probably a bug in React.',
        );
      }
      prepareToHydrateHostActivityInstance(workInProgress);
      bubbleProperties(workInProgress);
      if (enableProfilerTimer) {
        if ((workInProgress.mode & ProfileMode) !== NoMode) {
          const isTimedOutSuspense = nextState !== null;
          if (isTimedOutSuspense) {
            // Don't count time spent in a timed out Suspense subtree as part of the base duration.
            const primaryChildFragment = workInProgress.child;
            if (primaryChildFragment !== null) {
              // $FlowFixMe[unsafe-arithmetic] Flow doesn't support type casting in combination with the -= operator
              workInProgress.treeBaseDuration -=
                ((primaryChildFragment.treeBaseDuration: any): number);
            }
          }
        }
      }
      return false;
    } else {
      emitPendingHydrationWarnings();
      // We might have reentered this boundary to hydrate it. If so, we need to reset the hydration
      // state since we're now exiting out of it. popHydrationState doesn't do that for us.
      resetHydrationState();
      if ((workInProgress.flags & DidCapture) === NoFlags) {
        // This boundary did not suspend so it's now hydrated and unsuspended.
        nextState = workInProgress.memoizedState = null;
      }
      // If nothing suspended, we need to schedule an effect to mark this boundary
      // as having hydrated so events know that they're free to be invoked.
      // It's also a signal to replay events and the suspense callback.
      // If something suspended, schedule an effect to attach retry listeners.
      // So we might as well always mark this.
      workInProgress.flags |= Update;
      bubbleProperties(workInProgress);
      if (enableProfilerTimer) {
        if ((workInProgress.mode & ProfileMode) !== NoMode) {
          const isTimedOutSuspense = nextState !== null;
          if (isTimedOutSuspense) {
            // Don't count time spent in a timed out Suspense subtree as part of the base duration.
            const primaryChildFragment = workInProgress.child;
            if (primaryChildFragment !== null) {
              // $FlowFixMe[unsafe-arithmetic] Flow doesn't support type casting in combination with the -= operator
              workInProgress.treeBaseDuration -=
                ((primaryChildFragment.treeBaseDuration: any): number);
            }
          }
        }
      }
      return false;
    }
  } else {
    // Successfully completed this tree. If this was a forced client render,
    // there may have been recoverable errors during first hydration
    // attempt. If so, add them to a queue so we can log them in the
    // commit phase. We also add them to prev state so we can get to them
    // from the Suspense Boundary.
    const hydrationErrors = upgradeHydrationErrorsToRecoverable();
    if (current !== null && current.memoizedState !== null) {
      const prevState: ActivityState = current.memoizedState;
      prevState.hydrationErrors = hydrationErrors;
    }
    // Fall through to normal Offscreen path
    return true;
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does completeDehydratedActivityBoundary() do?
completeDehydratedActivityBoundary() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberCompleteWork.js.
Where is completeDehydratedActivityBoundary() defined?
completeDehydratedActivityBoundary() is defined in packages/react-reconciler/src/ReactFiberCompleteWork.js at line 904.
What does completeDehydratedActivityBoundary() call?
completeDehydratedActivityBoundary() calls 4 function(s): bubbleProperties, popHydrationState, prepareToHydrateHostActivityInstance, resetHydrationState.
What calls completeDehydratedActivityBoundary()?
completeDehydratedActivityBoundary() is called by 1 function(s): completeWork.

Analyze Your Own Codebase

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

Try Supermodel Free