Home / Function/ maybeDependency() — react Function Reference

maybeDependency() — react Function Reference

Architecture documentation for the maybeDependency() function in PropagateScopeDependenciesHIR.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  e434c5d6_d7c8_9e0b_09fc_dc6523d5ef77["maybeDependency()"]
  1be3b542_2ecf_364c_adef_6e5675b7385e["DependencyCollectionContext"]
  e434c5d6_d7c8_9e0b_09fc_dc6523d5ef77 -->|defined in| 1be3b542_2ecf_364c_adef_6e5675b7385e
  9b550baf_b3c9_a36a_101b_988d1ebb847c["isRefValueType()"]
  e434c5d6_d7c8_9e0b_09fc_dc6523d5ef77 -->|calls| 9b550baf_b3c9_a36a_101b_988d1ebb847c
  206bc538_facf_a3c4_b99c_e6c96e4aa11a["isObjectMethodType()"]
  e434c5d6_d7c8_9e0b_09fc_dc6523d5ef77 -->|calls| 206bc538_facf_a3c4_b99c_e6c96e4aa11a
  style e434c5d6_d7c8_9e0b_09fc_dc6523d5ef77 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/PropagateScopeDependenciesHIR.ts lines 489–517

  #checkValidDependency(maybeDependency: ReactiveScopeDependency): boolean {
    // ref value is not a valid dep
    if (isRefValueType(maybeDependency.identifier)) {
      return false;
    }

    /*
     * object methods are not deps because they will be codegen'ed back in to
     * the object literal.
     */
    if (isObjectMethodType(maybeDependency.identifier)) {
      return false;
    }

    const identifier = maybeDependency.identifier;
    /*
     * If this operand is used in a scope, has a dynamic value, and was defined
     * before this scope, then its a dependency of the scope.
     */
    const currentDeclaration =
      this.#reassignments.get(identifier) ??
      this.#declarations.get(identifier.declarationId);
    const currentScope = this.currentScope.value;
    return (
      currentScope != null &&
      currentDeclaration !== undefined &&
      currentDeclaration.id < currentScope.range.start
    );
  }

Subdomains

Frequently Asked Questions

What does maybeDependency() do?
maybeDependency() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/PropagateScopeDependenciesHIR.ts.
Where is maybeDependency() defined?
maybeDependency() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/PropagateScopeDependenciesHIR.ts at line 489.
What does maybeDependency() call?
maybeDependency() calls 2 function(s): isObjectMethodType, isRefValueType.

Analyze Your Own Codebase

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

Try Supermodel Free