Home / Function/ initTextarea() — react Function Reference

initTextarea() — react Function Reference

Architecture documentation for the initTextarea() function in ReactDOMTextarea.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  d7552454_ad8c_6921_661d_7d0abf4e6add["initTextarea()"]
  8997a27a_fcfe_cfbe_fe0c_b8a92dc76e38["ReactDOMTextarea.js"]
  d7552454_ad8c_6921_661d_7d0abf4e6add -->|defined in| 8997a27a_fcfe_cfbe_fe0c_b8a92dc76e38
  96cf114b_9b89_b174_432c_1584a973fcdd["setInitialProperties()"]
  96cf114b_9b89_b174_432c_1584a973fcdd -->|calls| d7552454_ad8c_6921_661d_7d0abf4e6add
  894d4888_e1c9_cdd6_e0cb_7451b6fba151["hydrateProperties()"]
  894d4888_e1c9_cdd6_e0cb_7451b6fba151 -->|calls| d7552454_ad8c_6921_661d_7d0abf4e6add
  7404ee30_0cd4_7886_2806_324f301962c4["getToStringValue()"]
  d7552454_ad8c_6921_661d_7d0abf4e6add -->|calls| 7404ee30_0cd4_7886_2806_324f301962c4
  49843596_bcbe_c41c_e960_1ffc711ed1ed["track()"]
  d7552454_ad8c_6921_661d_7d0abf4e6add -->|calls| 49843596_bcbe_c41c_e960_1ffc711ed1ed
  style d7552454_ad8c_6921_661d_7d0abf4e6add fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-dom-bindings/src/client/ReactDOMTextarea.js lines 93–148

export function initTextarea(
  element: Element,
  value: ?string,
  defaultValue: ?string,
  children: ?string,
) {
  const node: HTMLTextAreaElement = (element: any);

  let initialValue = value;

  // Only bother fetching default value if we're going to use it
  if (initialValue == null) {
    if (children != null) {
      if (!disableTextareaChildren) {
        if (defaultValue != null) {
          throw new Error(
            'If you supply `defaultValue` on a <textarea>, do not pass children.',
          );
        }

        if (isArray(children)) {
          if (children.length > 1) {
            throw new Error('<textarea> can only have at most one child.');
          }

          children = children[0];
        }

        defaultValue = children;
      }
    }
    if (defaultValue == null) {
      defaultValue = '';
    }
    initialValue = defaultValue;
  }

  const stringValue = getToStringValue(initialValue);
  node.defaultValue = (stringValue: any); // This will be toString:ed.

  // This is in postMount because we need access to the DOM node, which is not
  // available until after the component has mounted.
  const textContent = node.textContent;

  // Only set node.value if textContent is equal to the expected
  // initial value. In IE10/IE11 there is a bug where the placeholder attribute
  // will populate textContent as well.
  // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/
  if (textContent === stringValue) {
    if (textContent !== '' && textContent !== null) {
      node.value = textContent;
    }
  }

  track((element: any));
}

Domain

Subdomains

Frequently Asked Questions

What does initTextarea() do?
initTextarea() is a function in the react codebase, defined in packages/react-dom-bindings/src/client/ReactDOMTextarea.js.
Where is initTextarea() defined?
initTextarea() is defined in packages/react-dom-bindings/src/client/ReactDOMTextarea.js at line 93.
What does initTextarea() call?
initTextarea() calls 2 function(s): getToStringValue, track.
What calls initTextarea()?
initTextarea() is called by 2 function(s): hydrateProperties, setInitialProperties.

Analyze Your Own Codebase

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

Try Supermodel Free