Home / Function/ constructor() — react Function Reference

constructor() — react Function Reference

Architecture documentation for the constructor() function in DeriveMinimalDependenciesHIR.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  c3c6f6a8_c9a1_6bd6_1e19_d0b4daf01b4a["constructor()"]
  ce8ab5d9_db4b_3be5_3f9c_38fa68bcbaa1["ReactiveScopeDependencyTreeHIR"]
  c3c6f6a8_c9a1_6bd6_1e19_d0b4daf01b4a -->|defined in| ce8ab5d9_db4b_3be5_3f9c_38fa68bcbaa1
  041ca752_10c1_3cda_1f5c_02f44a01310e["invariant()"]
  c3c6f6a8_c9a1_6bd6_1e19_d0b4daf01b4a -->|calls| 041ca752_10c1_3cda_1f5c_02f44a01310e
  5a207168_ee92_cf3e_88f3_676a664d6583["constructor()"]
  c3c6f6a8_c9a1_6bd6_1e19_d0b4daf01b4a -->|calls| 5a207168_ee92_cf3e_88f3_676a664d6583
  style c3c6f6a8_c9a1_6bd6_1e19_d0b4daf01b4a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/DeriveMinimalDependenciesHIR.ts lines 38–71

  constructor(hoistableObjects: Iterable<ReactiveScopeDependency>) {
    for (const {path, identifier, reactive} of hoistableObjects) {
      let currNode = ReactiveScopeDependencyTreeHIR.#getOrCreateRoot(
        identifier,
        reactive,
        this.#hoistableObjects,
        path.length > 0 && path[0].optional ? 'Optional' : 'NonNull',
      );

      for (let i = 0; i < path.length; i++) {
        const prevAccessType = currNode.properties.get(
          path[i].property,
        )?.accessType;
        const accessType =
          i + 1 < path.length && path[i + 1].optional ? 'Optional' : 'NonNull';
        CompilerError.invariant(
          prevAccessType == null || prevAccessType === accessType,
          {
            reason: 'Conflicting access types',
            loc: GeneratedSource,
          },
        );
        let nextNode = currNode.properties.get(path[i].property);
        if (nextNode == null) {
          nextNode = {
            properties: new Map(),
            accessType,
          };
          currNode.properties.set(path[i].property, nextNode);
        }
        currNode = nextNode;
      }
    }
  }

Subdomains

Frequently Asked Questions

What does constructor() do?
constructor() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/DeriveMinimalDependenciesHIR.ts.
Where is constructor() defined?
constructor() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/DeriveMinimalDependenciesHIR.ts at line 38.
What does constructor() call?
constructor() calls 2 function(s): constructor, invariant.

Analyze Your Own Codebase

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

Try Supermodel Free