Home / Function/ prepareToHydrateHostTextInstance() — react Function Reference

prepareToHydrateHostTextInstance() — react Function Reference

Architecture documentation for the prepareToHydrateHostTextInstance() function in ReactFiberHydrationContext.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  0c745329_8d79_5006_cb91_2a5765029a9b["prepareToHydrateHostTextInstance()"]
  4bc7109f_638d_d9f7_bf47_6ec55b2fa128["ReactFiberHydrationContext.js"]
  0c745329_8d79_5006_cb91_2a5765029a9b -->|defined in| 4bc7109f_638d_d9f7_bf47_6ec55b2fa128
  0b8db832_87fd_e560_8aa8_e2b319c81626["completeWork()"]
  0b8db832_87fd_e560_8aa8_e2b319c81626 -->|calls| 0c745329_8d79_5006_cb91_2a5765029a9b
  0a0d4387_d230_00e3_0763_8da5f624b610["buildHydrationDiffNode()"]
  0c745329_8d79_5006_cb91_2a5765029a9b -->|calls| 0a0d4387_d230_00e3_0763_8da5f624b610
  80ab8739_b87f_ce9e_47e3_2b23b5998883["throwOnHydrationMismatch()"]
  0c745329_8d79_5006_cb91_2a5765029a9b -->|calls| 80ab8739_b87f_ce9e_47e3_2b23b5998883
  style 0c745329_8d79_5006_cb91_2a5765029a9b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-reconciler/src/ReactFiberHydrationContext.js lines 566–630

function prepareToHydrateHostTextInstance(fiber: Fiber): void {
  if (!supportsHydration) {
    throw new Error(
      'Expected prepareToHydrateHostTextInstance() to never be called. ' +
        'This error is likely caused by a bug in React. Please file an issue.',
    );
  }

  const textInstance: TextInstance = fiber.stateNode;
  const textContent: string = fiber.memoizedProps;
  const shouldWarnIfMismatchDev = !didSuspendOrErrorDEV;
  let parentProps = null;
  // We assume that prepareToHydrateHostTextInstance is called in a context where the
  // hydration parent is the parent host component of this host text.
  const returnFiber = hydrationParentFiber;
  if (returnFiber !== null) {
    switch (returnFiber.tag) {
      case HostRoot: {
        if (__DEV__) {
          if (shouldWarnIfMismatchDev) {
            const difference = diffHydratedTextForDevWarnings(
              textInstance,
              textContent,
              parentProps,
            );
            if (difference !== null) {
              const diffNode = buildHydrationDiffNode(fiber, 0);
              diffNode.serverProps = difference;
            }
          }
        }
        break;
      }
      case HostSingleton:
      case HostComponent: {
        parentProps = returnFiber.memoizedProps;
        if (__DEV__) {
          if (shouldWarnIfMismatchDev) {
            const difference = diffHydratedTextForDevWarnings(
              textInstance,
              textContent,
              parentProps,
            );
            if (difference !== null) {
              const diffNode = buildHydrationDiffNode(fiber, 0);
              diffNode.serverProps = difference;
            }
          }
        }
        break;
      }
    }
    // TODO: What if it's a SuspenseInstance?
  }

  const didHydrate = hydrateTextInstance(
    textInstance,
    textContent,
    fiber,
    parentProps,
  );
  if (!didHydrate) {
    throwOnHydrationMismatch(fiber, true);
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does prepareToHydrateHostTextInstance() do?
prepareToHydrateHostTextInstance() is a function in the react codebase, defined in packages/react-reconciler/src/ReactFiberHydrationContext.js.
Where is prepareToHydrateHostTextInstance() defined?
prepareToHydrateHostTextInstance() is defined in packages/react-reconciler/src/ReactFiberHydrationContext.js at line 566.
What does prepareToHydrateHostTextInstance() call?
prepareToHydrateHostTextInstance() calls 2 function(s): buildHydrationDiffNode, throwOnHydrationMismatch.
What calls prepareToHydrateHostTextInstance()?
prepareToHydrateHostTextInstance() 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