Home / Function/ getOrCreateProperty() — react Function Reference

getOrCreateProperty() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  afcd35a2_87ac_64f3_d39b_e78954698dc0["getOrCreateProperty()"]
  50c372df_146d_1b4c_de3a_0589d6591a75["PropertyPathRegistry"]
  afcd35a2_87ac_64f3_d39b_e78954698dc0 -->|defined in| 50c372df_146d_1b4c_de3a_0589d6591a75
  618d3d38_bcbf_713e_ce1a_d85056287498["getMaybeNonNullInInstruction()"]
  618d3d38_bcbf_713e_ce1a_d85056287498 -->|calls| afcd35a2_87ac_64f3_d39b_e78954698dc0
  2c85e7b5_d003_b439_dc7b_cb881996ea23["collectNonNullsInBlocks()"]
  2c85e7b5_d003_b439_dc7b_cb881996ea23 -->|calls| afcd35a2_87ac_64f3_d39b_e78954698dc0
  084ee472_d720_c32a_2f8a_dffbbb1be6af["getOrCreateIdentifier()"]
  afcd35a2_87ac_64f3_d39b_e78954698dc0 -->|calls| 084ee472_d720_c32a_2f8a_dffbbb1be6af
  a6cc066a_d685_3022_a631_437bad493e6d["getOrCreatePropertyEntry()"]
  afcd35a2_87ac_64f3_d39b_e78954698dc0 -->|calls| a6cc066a_d685_3022_a631_437bad493e6d
  style afcd35a2_87ac_64f3_d39b_e78954698dc0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts lines 301–322

  getOrCreateProperty(n: ReactiveScopeDependency): PropertyPathNode {
    /**
     * We add ReactiveScopeDependencies according to instruction ordering,
     * so all subpaths of a PropertyLoad should already exist
     * (e.g. a.b is added before a.b.c),
     */
    let currNode = this.getOrCreateIdentifier(n.identifier, n.reactive);
    if (n.path.length === 0) {
      return currNode;
    }
    for (let i = 0; i < n.path.length - 1; i++) {
      currNode = PropertyPathRegistry.getOrCreatePropertyEntry(
        currNode,
        n.path[i],
      );
    }

    return PropertyPathRegistry.getOrCreatePropertyEntry(
      currNode,
      n.path.at(-1)!,
    );
  }

Subdomains

Frequently Asked Questions

What does getOrCreateProperty() do?
getOrCreateProperty() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts.
Where is getOrCreateProperty() defined?
getOrCreateProperty() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts at line 301.
What does getOrCreateProperty() call?
getOrCreateProperty() calls 2 function(s): getOrCreateIdentifier, getOrCreatePropertyEntry.
What calls getOrCreateProperty()?
getOrCreateProperty() is called by 2 function(s): collectNonNullsInBlocks, getMaybeNonNullInInstruction.

Analyze Your Own Codebase

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

Try Supermodel Free