Home / Function/ visitScope() — react Function Reference

visitScope() — react Function Reference

Architecture documentation for the visitScope() function in PruneInitializationDependencies.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  eb5a8bba_982f_3e93_34ad_57191041e6d7["visitScope()"]
  e1b0b28f_0a55_63f6_4092_ecaa28a68023["Visitor"]
  eb5a8bba_982f_3e93_34ad_57191041e6d7 -->|defined in| e1b0b28f_0a55_63f6_4092_ecaa28a68023
  a7715c66_6895_207b_7553_143987538107["join()"]
  eb5a8bba_982f_3e93_34ad_57191041e6d7 -->|calls| a7715c66_6895_207b_7553_143987538107
  4acb57df_5348_9aab_9691_41cf35127db4["visitScope()"]
  eb5a8bba_982f_3e93_34ad_57191041e6d7 -->|calls| 4acb57df_5348_9aab_9691_41cf35127db4
  4c434fb2_75ab_6c2c_c237_b1d38a1b0141["forEach()"]
  eb5a8bba_982f_3e93_34ad_57191041e6d7 -->|calls| 4c434fb2_75ab_6c2c_c237_b1d38a1b0141
  74efde51_a311_d84c_0e23_ddafd072e338["find()"]
  eb5a8bba_982f_3e93_34ad_57191041e6d7 -->|calls| 74efde51_a311_d84c_0e23_ddafd072e338
  style eb5a8bba_982f_3e93_34ad_57191041e6d7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneInitializationDependencies.ts lines 173–191

  override visitScope(scope: ReactiveScopeBlock): void {
    const state = this.join(
      [
        ...scope.scope.declarations.keys(),
        ...[...scope.scope.reassignments.values()].map(ident => ident.id),
      ].map(id => this.map.get(id) ?? 'Unknown'),
    );
    super.visitScope(scope, state);
    [...scope.scope.dependencies].forEach(ident => {
      let target: undefined | IdentifierId =
        this.aliases.find(ident.identifier.id) ?? ident.identifier.id;
      ident.path.forEach(token => {
        target &&= this.paths.get(target)?.get(token.property);
      });
      if (target && this.map.get(target) === 'Create') {
        scope.scope.dependencies.delete(ident);
      }
    });
  }

Domain

Subdomains

Frequently Asked Questions

What does visitScope() do?
visitScope() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneInitializationDependencies.ts.
Where is visitScope() defined?
visitScope() is defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneInitializationDependencies.ts at line 173.
What does visitScope() call?
visitScope() calls 4 function(s): find, forEach, join, visitScope.

Analyze Your Own Codebase

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

Try Supermodel Free