Home / Function/ Component() — react Function Reference

Component() — react Function Reference

Architecture documentation for the Component() function in escape-analysis-non-escaping-interleaved-allocating-nested-dependency.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  bd83fb0a_cc88_00e3_7053_2023baa2d89f["Component()"]
  1d70bb47_59da_2535_e22b_d4f50495da79["escape-analysis-non-escaping-interleaved-allocating-nested-dependency.js"]
  bd83fb0a_cc88_00e3_7053_2023baa2d89f -->|defined in| 1d70bb47_59da_2535_e22b_d4f50495da79
  style bd83fb0a_cc88_00e3_7053_2023baa2d89f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-allocating-nested-dependency.js lines 1–24

function Component(props) {
  // a can be independently memoized, is not mutated later
  // but a is a dependnecy of b, which is a dependency of c.
  // we have to memoize a to avoid breaking memoization of b,
  // to avoid breaking memoization of c.
  const a = [props.a];

  // a can be independently memoized, is not mutated later,
  // but is a dependency of d which is part of c's scope.
  // we have to memoize b to avoid breaking memoization of c.
  const b = [a];

  // c and d are interleaved and grouped into a single scope,
  // but they are independent values. d does not escape, but
  // we need to ensure that b is memoized or else b will invalidate
  // on every render since a is a dependency. we also need to
  // ensure that a is memoized, since it's a dependency of b.
  const c = [];
  const d = {};
  d.b = b;
  c.push(props.b);

  return c;
}

Subdomains

Frequently Asked Questions

What does Component() do?
Component() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-allocating-nested-dependency.js.
Where is Component() defined?
Component() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-allocating-nested-dependency.js at line 1.

Analyze Your Own Codebase

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

Try Supermodel Free