Home / Function/ __printTree() — react Function Reference

__printTree() — react Function Reference

Architecture documentation for the __printTree() function in CommitTreeBuilder.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  33ca2f10_d88b_7770_5dec_f17ab5a7f5e9["__printTree()"]
  9a35328e_d36f_c6be_c574_b617a15cc7b2["CommitTreeBuilder.js"]
  33ca2f10_d88b_7770_5dec_f17ab5a7f5e9 -->|defined in| 9a35328e_d36f_c6be_c574_b617a15cc7b2
  style 33ca2f10_d88b_7770_5dec_f17ab5a7f5e9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js lines 508–538

const __printTree = (commitTree: CommitTree) => {
  if (__DEBUG__) {
    const {nodes, rootID} = commitTree;
    console.group('__printTree()');
    const queue = [rootID, 0];
    while (queue.length > 0) {
      const id = queue.shift();
      const depth = queue.shift();

      // $FlowFixMe[incompatible-call]
      const node = nodes.get(id);
      if (node == null) {
        // $FlowFixMe[incompatible-type]
        throw Error(`Could not find node with id "${id}" in commit tree`);
      }

      console.log(
        // $FlowFixMe[incompatible-call]
        `${'•'.repeat(depth)}${node.id}:${node.displayName || ''} ${
          node.key ? `key:"${node.key}"` : ''
        } (${node.treeBaseDuration})`,
      );

      node.children.forEach(childID => {
        // $FlowFixMe[unsafe-addition]
        queue.push(childID, depth + 1);
      });
    }
    console.groupEnd();
  }
};

Domain

Subdomains

Frequently Asked Questions

What does __printTree() do?
__printTree() is a function in the react codebase, defined in packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js.
Where is __printTree() defined?
__printTree() is defined in packages/react-devtools-shared/src/devtools/views/Profiler/CommitTreeBuilder.js at line 508.

Analyze Your Own Codebase

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

Try Supermodel Free