Home / Function/ keyByScopeId() — react Function Reference

keyByScopeId() — react Function Reference

Architecture documentation for the keyByScopeId() function in CollectHoistablePropertyLoads.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  9feae12a_25c0_ee10_d379_b2494a720a79["keyByScopeId()"]
  53e05ed1_ffb1_8db2_8573_ef5a3fb99c72["CollectHoistablePropertyLoads.ts"]
  9feae12a_25c0_ee10_d379_b2494a720a79 -->|defined in| 53e05ed1_ffb1_8db2_8573_ef5a3fb99c72
  55f3fce3_0db5_e260_b549_d5a721561462["propagateScopeDependenciesHIR()"]
  55f3fce3_0db5_e260_b549_d5a721561462 -->|calls| 9feae12a_25c0_ee10_d379_b2494a720a79
  style 9feae12a_25c0_ee10_d379_b2494a720a79 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts lines 196–210

export function keyByScopeId<T>(
  fn: HIRFunction,
  source: ReadonlyMap<BlockId, T>,
): ReadonlyMap<ScopeId, T> {
  const keyedByScopeId = new Map<ScopeId, T>();
  for (const [_, block] of fn.body.blocks) {
    if (block.terminal.kind === 'scope') {
      keyedByScopeId.set(
        block.terminal.scope.id,
        source.get(block.terminal.block)!,
      );
    }
  }
  return keyedByScopeId;
}

Subdomains

Frequently Asked Questions

What does keyByScopeId() do?
keyByScopeId() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts.
Where is keyByScopeId() defined?
keyByScopeId() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts at line 196.
What calls keyByScopeId()?
keyByScopeId() is called by 1 function(s): propagateScopeDependenciesHIR.

Analyze Your Own Codebase

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

Try Supermodel Free