Home / Function/ getChildren() — react Function Reference

getChildren() — react Function Reference

Architecture documentation for the getChildren() function in renderer.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  2f227955_4f5b_a05f_26dc_975311221f5d["getChildren()"]
  27444ff2_8253_76db_da6c_4967b0d20cee["renderer.js"]
  2f227955_4f5b_a05f_26dc_975311221f5d -->|defined in| 27444ff2_8253_76db_da6c_4967b0d20cee
  0bf1ec3e_7bcf_3a31_d050_f4e3bd960b04["attach()"]
  0bf1ec3e_7bcf_3a31_d050_f4e3bd960b04 -->|calls| 2f227955_4f5b_a05f_26dc_975311221f5d
  cc77e32e_65f2_bb71_c3b3_89c3ff8f9852["getElementType()"]
  2f227955_4f5b_a05f_26dc_975311221f5d -->|calls| cc77e32e_65f2_bb71_c3b3_89c3ff8f9852
  style 2f227955_4f5b_a05f_26dc_975311221f5d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-shared/src/backend/legacy/renderer.js lines 104–134

function getChildren(internalInstance: Object): Array<any> {
  const children = [];

  // If the parent is a native node without rendered children, but with
  // multiple string children, then the `element` that gets passed in here is
  // a plain value -- a string or number.
  if (typeof internalInstance !== 'object') {
    // No children
  } else if (
    internalInstance._currentElement === null ||
    internalInstance._currentElement === false
  ) {
    // No children
  } else if (internalInstance._renderedComponent) {
    const child = internalInstance._renderedComponent;
    if (getElementType(child) !== ElementTypeOtherOrUnknown) {
      children.push(child);
    }
  } else if (internalInstance._renderedChildren) {
    const renderedChildren = internalInstance._renderedChildren;
    for (const name in renderedChildren) {
      const child = renderedChildren[name];
      if (getElementType(child) !== ElementTypeOtherOrUnknown) {
        children.push(child);
      }
    }
  }
  // Note: we skip the case where children are just strings or numbers
  // because the new DevTools skips over host text nodes anyway.
  return children;
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does getChildren() do?
getChildren() is a function in the react codebase, defined in packages/react-devtools-shared/src/backend/legacy/renderer.js.
Where is getChildren() defined?
getChildren() is defined in packages/react-devtools-shared/src/backend/legacy/renderer.js at line 104.
What does getChildren() call?
getChildren() calls 1 function(s): getElementType.
What calls getChildren()?
getChildren() is called by 1 function(s): attach.

Analyze Your Own Codebase

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

Try Supermodel Free