Home / Function/ hydrateText() — react Function Reference

hydrateText() — react Function Reference

Architecture documentation for the hydrateText() function in ReactDOMComponent.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  77f4e8f0_f9b0_3782_0fdd_8c9f87346e83["hydrateText()"]
  1e990658_7cea_75be_1f24_2399bdf9f15b["ReactDOMComponent.js"]
  77f4e8f0_f9b0_3782_0fdd_8c9f87346e83 -->|defined in| 1e990658_7cea_75be_1f24_2399bdf9f15b
  ddbc1690_cbca_9f67_caf6_506c865c480a["checkForUnmatchedText()"]
  77f4e8f0_f9b0_3782_0fdd_8c9f87346e83 -->|calls| ddbc1690_cbca_9f67_caf6_506c865c480a
  8c4ad254_8dbf_cbef_d7da_cf083fdc32da["normalizeMarkupForTextOrAttribute()"]
  77f4e8f0_f9b0_3782_0fdd_8c9f87346e83 -->|calls| 8c4ad254_8dbf_cbef_d7da_cf083fdc32da
  eb91f874_8ee4_2703_d333_d67f28ac1a0b["restoreControlledInputState()"]
  77f4e8f0_f9b0_3782_0fdd_8c9f87346e83 -->|calls| eb91f874_8ee4_2703_d333_d67f28ac1a0b
  818aa739_0963_67a6_c011_005a9880a465["restoreControlledTextareaState()"]
  77f4e8f0_f9b0_3782_0fdd_8c9f87346e83 -->|calls| 818aa739_0963_67a6_c011_005a9880a465
  0a457bc2_7367_4026_f6c7_1787c9327604["restoreControlledSelectState()"]
  77f4e8f0_f9b0_3782_0fdd_8c9f87346e83 -->|calls| 0a457bc2_7367_4026_f6c7_1787c9327604
  style 77f4e8f0_f9b0_3782_0fdd_8c9f87346e83 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-dom-bindings/src/client/ReactDOMComponent.js lines 3333–3379

export function hydrateText(
  textNode: Text,
  text: string,
  parentProps: null | Object,
): boolean {
  const isDifferent = textNode.nodeValue !== text;
  if (
    isDifferent &&
    (parentProps === null || parentProps.suppressHydrationWarning !== true) &&
    !checkForUnmatchedText(textNode.nodeValue, text)
  ) {
    return false;
  }
  return true;
}

export function diffHydratedText(textNode: Text, text: string): null | string {
  if (textNode.nodeValue === text) {
    return null;
  }
  const normalizedClientText = normalizeMarkupForTextOrAttribute(text);
  const normalizedServerText = normalizeMarkupForTextOrAttribute(
    textNode.nodeValue,
  );
  if (normalizedServerText === normalizedClientText) {
    return null;
  }
  return textNode.nodeValue;
}

export function restoreControlledState(
  domElement: Element,
  tag: string,
  props: Object,
): void {
  switch (tag) {
    case 'input':
      restoreControlledInputState(domElement, props);
      return;
    case 'textarea':
      restoreControlledTextareaState(domElement, props);
      return;
    case 'select':
      restoreControlledSelectState(domElement, props);
      return;
  }
}

Domain

Subdomains

Frequently Asked Questions

What does hydrateText() do?
hydrateText() is a function in the react codebase, defined in packages/react-dom-bindings/src/client/ReactDOMComponent.js.
Where is hydrateText() defined?
hydrateText() is defined in packages/react-dom-bindings/src/client/ReactDOMComponent.js at line 3333.
What does hydrateText() call?
hydrateText() calls 5 function(s): checkForUnmatchedText, normalizeMarkupForTextOrAttribute, restoreControlledInputState, restoreControlledSelectState, restoreControlledTextareaState.

Analyze Your Own Codebase

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

Try Supermodel Free