Home / Function/ visitScope() — react Function Reference

visitScope() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  8e7603e1_e406_67bf_e050_540df344e5ff["visitScope()"]
  5cd10448_f0eb_0786_b718_13989afbbde5["Visitor"]
  8e7603e1_e406_67bf_e050_540df344e5ff -->|defined in| 5cd10448_f0eb_0786_b718_13989afbbde5
  2eebfc2b_b1f6_9f25_ad32_78be0b56f06b["traverseScope()"]
  8e7603e1_e406_67bf_e050_540df344e5ff -->|calls| 2eebfc2b_b1f6_9f25_ad32_78be0b56f06b
  4acb57df_5348_9aab_9691_41cf35127db4["visitScope()"]
  8e7603e1_e406_67bf_e050_540df344e5ff -->|calls| 4acb57df_5348_9aab_9691_41cf35127db4
  325a6f42_549f_1115_a1f6_935e8be237cc["isUnmemoized()"]
  8e7603e1_e406_67bf_e050_540df344e5ff -->|calls| 325a6f42_549f_1115_a1f6_935e8be237cc
  style 8e7603e1_e406_67bf_e050_540df344e5ff fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateMemoizedEffectDependencies.ts lines 63–89

  override visitScope(
    scopeBlock: ReactiveScopeBlock,
    state: CompilerError,
  ): void {
    this.traverseScope(scopeBlock, state);

    /*
     * Record scopes that exist in the AST so we can later check to see if
     * effect dependencies which should be memoized (have a scope assigned)
     * actually are memoized (that scope exists).
     * However, we only record scopes if *their* dependencies are also
     * memoized, allowing a transitive memoization check.
     */
    let areDependenciesMemoized = true;
    for (const dep of scopeBlock.scope.dependencies) {
      if (isUnmemoized(dep.identifier, this.scopes)) {
        areDependenciesMemoized = false;
        break;
      }
    }
    if (areDependenciesMemoized) {
      this.scopes.add(scopeBlock.scope.id);
      for (const id of scopeBlock.scope.merged) {
        this.scopes.add(id);
      }
    }
  }

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/Validation/ValidateMemoizedEffectDependencies.ts.
Where is visitScope() defined?
visitScope() is defined in compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateMemoizedEffectDependencies.ts at line 63.
What does visitScope() call?
visitScope() calls 3 function(s): isUnmemoized, traverseScope, visitScope.

Analyze Your Own Codebase

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

Try Supermodel Free