Home / Class/ Visitor Class — react Architecture

Visitor Class — react Architecture

Architecture documentation for the Visitor class in CollectReferencedGlobals.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  b770ac0c_31b2_e0e1_e263_5ad9b2e589a6["Visitor"]
  912711a8_8fb0_c4ab_294c_3ee046affe17["CollectReferencedGlobals.ts"]
  b770ac0c_31b2_e0e1_e263_5ad9b2e589a6 -->|defined in| 912711a8_8fb0_c4ab_294c_3ee046affe17
  59466e3c_8dff_c1c6_a9da_43f2174f7c1b["visitValue()"]
  b770ac0c_31b2_e0e1_e263_5ad9b2e589a6 -->|method| 59466e3c_8dff_c1c6_a9da_43f2174f7c1b
  7df374d3_bd11_ce99_3ad4_bdac1fc40fd0["visitReactiveFunctionValue()"]
  b770ac0c_31b2_e0e1_e263_5ad9b2e589a6 -->|method| 7df374d3_bd11_ce99_3ad4_bdac1fc40fd0

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CollectReferencedGlobals.ts lines 21–43

class Visitor extends ReactiveFunctionVisitor<Set<string>> {
  override visitValue(
    id: InstructionId,
    value: ReactiveValue,
    state: Set<string>,
  ): void {
    this.traverseValue(id, value, state);
    if (value.kind === 'FunctionExpression' || value.kind === 'ObjectMethod') {
      this.visitHirFunction(value.loweredFunc.func, state);
    } else if (value.kind === 'LoadGlobal') {
      state.add(value.binding.name);
    }
  }

  override visitReactiveFunctionValue(
    _id: InstructionId,
    _dependencies: Array<Place>,
    fn: ReactiveFunction,
    state: Set<string>,
  ): void {
    visitReactiveFunction(fn, this, state);
  }
}

Domain

Frequently Asked Questions

What is the Visitor class?
Visitor is a class in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CollectReferencedGlobals.ts.
Where is Visitor defined?
Visitor is defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CollectReferencedGlobals.ts at line 21.

Analyze Your Own Codebase

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

Try Supermodel Free