Home / Function/ Component() — react Function Reference

Component() — react Function Reference

Architecture documentation for the Component() function in reactivity-via-readonly-alias-of-mutable-value.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  ba4985f7_5a57_e321_968e_6b6dff3ff566["Component()"]
  731f02fc_ea30_1d07_249e_7ff388c7b630["reactivity-via-readonly-alias-of-mutable-value.js"]
  ba4985f7_5a57_e321_968e_6b6dff3ff566 -->|defined in| 731f02fc_ea30_1d07_249e_7ff388c7b630
  style ba4985f7_5a57_e321_968e_6b6dff3ff566 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reactivity-via-readonly-alias-of-mutable-value.js lines 1–22

function Component(props) {
  const x = [];
  const y = x;

  // y isn't reactive yet when we first visit this, so z is initially non-reactive
  const z = [y];

  // then we realize y is reactive. we need a fixpoint to propagate this back to z
  y.push(props.input);

  // PruneNonReactiveDependencies partially propagates reactivity (for now) which
  // we bypass with an indirection of storing into another variable
  const a = [z];

  // b's value is conditional on `a`, which is reactive per above
  let b = 0;
  if (a[0][0][0] === 42) {
    b = 1;
  }

  return [b];
}

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/reactivity-via-readonly-alias-of-mutable-value.js.
Where is Component() defined?
Component() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reactivity-via-readonly-alias-of-mutable-value.js at line 1.

Analyze Your Own Codebase

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

Try Supermodel Free