Home / Function/ renderTree() — react Function Reference

renderTree() — react Function Reference

Architecture documentation for the renderTree() function in ValidateNoDerivedComputationsInEffects_exp.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  7845cbdb_3287_8f3c_a65d_b843f74bf446["renderTree()"]
  a38a9d1f_969c_8056_aa80_6cb5fedba226["ValidateNoDerivedComputationsInEffects_exp.ts"]
  7845cbdb_3287_8f3c_a65d_b843f74bf446 -->|defined in| a38a9d1f_969c_8056_aa80_6cb5fedba226
  8014ef2c_7e1b_b1da_b888_615d609f3c01["validateEffect()"]
  8014ef2c_7e1b_b1da_b888_615d609f3c01 -->|calls| 7845cbdb_3287_8f3c_a65d_b843f74bf446
  style 7845cbdb_3287_8f3c_a65d_b843f74bf446 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoDerivedComputationsInEffects_exp.ts lines 569–609

function renderTree(
  node: TreeNode,
  indent: string = '',
  isLast: boolean = true,
  propsSet: Set<string>,
  stateSet: Set<string>,
): string {
  const prefix = indent + (isLast ? '└── ' : '├── ');
  const childIndent = indent + (isLast ? '    ' : '│   ');

  let result = `${prefix}${node.name}`;

  if (node.isSource) {
    let typeLabel: string;
    if (node.typeOfValue === 'fromProps') {
      propsSet.add(node.name);
      typeLabel = 'Prop';
    } else if (node.typeOfValue === 'fromState') {
      stateSet.add(node.name);
      typeLabel = 'State';
    } else {
      propsSet.add(node.name);
      stateSet.add(node.name);
      typeLabel = 'Prop and State';
    }
    result += ` (${typeLabel})`;
  }

  if (node.children.length > 0) {
    result += '\n';
    node.children.forEach((child, index) => {
      const isLastChild = index === node.children.length - 1;
      result += renderTree(child, childIndent, isLastChild, propsSet, stateSet);
      if (index < node.children.length - 1) {
        result += '\n';
      }
    });
  }

  return result;
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does renderTree() do?
renderTree() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoDerivedComputationsInEffects_exp.ts.
Where is renderTree() defined?
renderTree() is defined in compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoDerivedComputationsInEffects_exp.ts at line 569.
What calls renderTree()?
renderTree() is called by 1 function(s): validateEffect.

Analyze Your Own Codebase

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

Try Supermodel Free