Home / Function/ collectHoistablePropertyLoads() — react Function Reference

collectHoistablePropertyLoads() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  bff0b2a9_918b_8c37_61b5_56f59c89a9a1["collectHoistablePropertyLoads()"]
  53e05ed1_ffb1_8db2_8573_ef5a3fb99c72["CollectHoistablePropertyLoads.ts"]
  bff0b2a9_918b_8c37_61b5_56f59c89a9a1 -->|defined in| 53e05ed1_ffb1_8db2_8573_ef5a3fb99c72
  55f3fce3_0db5_e260_b549_d5a721561462["propagateScopeDependenciesHIR()"]
  55f3fce3_0db5_e260_b549_d5a721561462 -->|calls| bff0b2a9_918b_8c37_61b5_56f59c89a9a1
  bb062ddc_03b9_8460_2af6_d98cc2189d33["collectHoistablePropertyLoadsImpl()"]
  bff0b2a9_918b_8c37_61b5_56f59c89a9a1 -->|calls| bb062ddc_03b9_8460_2af6_d98cc2189d33
  30edbd1d_6244_d8ca_6be9_9380bed866cf["getAssumedInvokedFunctions()"]
  bff0b2a9_918b_8c37_61b5_56f59c89a9a1 -->|calls| 30edbd1d_6244_d8ca_6be9_9380bed866cf
  style bff0b2a9_918b_8c37_61b5_56f59c89a9a1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts lines 98–130

export function collectHoistablePropertyLoads(
  fn: HIRFunction,
  temporaries: ReadonlyMap<IdentifierId, ReactiveScopeDependency>,
  hoistableFromOptionals: ReadonlyMap<BlockId, ReactiveScopeDependency>,
): ReadonlyMap<BlockId, BlockInfo> {
  const registry = new PropertyPathRegistry();
  /**
   * Due to current limitations of mutable range inference, there are edge cases in
   * which we infer known-immutable values (e.g. props or hook params) to have a
   * mutable range and scope.
   * (see `destructure-array-declaration-to-context-var` fixture)
   * We track known immutable identifiers to reduce regressions (as PropagateScopeDeps
   * is being rewritten to HIR).
   */
  const knownImmutableIdentifiers = new Set<IdentifierId>();
  if (fn.fnType === 'Component' || fn.fnType === 'Hook') {
    for (const p of fn.params) {
      if (p.kind === 'Identifier') {
        knownImmutableIdentifiers.add(p.identifier.id);
      }
    }
  }
  return collectHoistablePropertyLoadsImpl(fn, {
    temporaries,
    knownImmutableIdentifiers,
    hoistableFromOptionals,
    registry,
    nestedFnImmutableContext: null,
    assumedInvokedFns: fn.env.config.enableTreatFunctionDepsAsConditional
      ? new Set()
      : getAssumedInvokedFunctions(fn),
  });
}

Subdomains

Frequently Asked Questions

What does collectHoistablePropertyLoads() do?
collectHoistablePropertyLoads() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts.
Where is collectHoistablePropertyLoads() defined?
collectHoistablePropertyLoads() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts at line 98.
What does collectHoistablePropertyLoads() call?
collectHoistablePropertyLoads() calls 2 function(s): collectHoistablePropertyLoadsImpl, getAssumedInvokedFunctions.
What calls collectHoistablePropertyLoads()?
collectHoistablePropertyLoads() 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