Home / Function/ traverseFunction() — react Function Reference

traverseFunction() — react Function Reference

Architecture documentation for the traverseFunction() function in CollectOptionalChainDependencies.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  9f4cf94f_95fc_c715_8c19_d3886a1e066d["traverseFunction()"]
  fd3023fa_cdd5_e8f0_669a_c459a0f89746["CollectOptionalChainDependencies.ts"]
  9f4cf94f_95fc_c715_8c19_d3886a1e066d -->|defined in| fd3023fa_cdd5_e8f0_669a_c459a0f89746
  ef81e884_f545_95f9_d420_7fcb2bd33ee0["collectOptionalChainSidemap()"]
  ef81e884_f545_95f9_d420_7fcb2bd33ee0 -->|calls| 9f4cf94f_95fc_c715_8c19_d3886a1e066d
  8e720f44_2b97_3d0b_5bc7_8a340dc6f442["traverseOptionalBlock()"]
  9f4cf94f_95fc_c715_8c19_d3886a1e066d -->|calls| 8e720f44_2b97_3d0b_5bc7_8a340dc6f442
  style 9f4cf94f_95fc_c715_8c19_d3886a1e066d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/CollectOptionalChainDependencies.ts lines 129–157

function traverseFunction(
  fn: HIRFunction,
  context: OptionalTraversalContext,
): void {
  for (const [_, block] of fn.body.blocks) {
    for (const instr of block.instructions) {
      if (
        instr.value.kind === 'FunctionExpression' ||
        instr.value.kind === 'ObjectMethod'
      ) {
        traverseFunction(instr.value.loweredFunc.func, {
          ...context,
          currFn: instr.value.loweredFunc.func,
          blocks: instr.value.loweredFunc.func.body.blocks,
        });
      }
    }
    if (
      block.terminal.kind === 'optional' &&
      !context.seenOptionals.has(block.id)
    ) {
      traverseOptionalBlock(
        block as TBasicBlock<OptionalTerminal>,
        context,
        null,
      );
    }
  }
}

Subdomains

Frequently Asked Questions

What does traverseFunction() do?
traverseFunction() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/CollectOptionalChainDependencies.ts.
Where is traverseFunction() defined?
traverseFunction() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/CollectOptionalChainDependencies.ts at line 129.
What does traverseFunction() call?
traverseFunction() calls 1 function(s): traverseOptionalBlock.
What calls traverseFunction()?
traverseFunction() is called by 1 function(s): collectOptionalChainSidemap.

Analyze Your Own Codebase

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

Try Supermodel Free