Home / Function/ Component() — react Function Reference

Component() — react Function Reference

Architecture documentation for the Component() function in reactive-control-dependency-reactive-after-fixpoint.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  0976425f_f2e0_bae2_8f86_3c30b780552b["Component()"]
  f1f83184_39d8_4b51_06f4_a2755e88b014["reactive-control-dependency-reactive-after-fixpoint.js"]
  0976425f_f2e0_bae2_8f86_3c30b780552b -->|defined in| f1f83184_39d8_4b51_06f4_a2755e88b014
  style 0976425f_f2e0_bae2_8f86_3c30b780552b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reactive-control-dependency-reactive-after-fixpoint.js lines 1–26

function Component(props) {
  let x = 0;

  let value = null;
  loop: for (let i = 0; i < 10; i++) {
    switch (value) {
      case true: {
        x = 1;
        break loop;
      }
      case false: {
        x = 2;
        break loop;
      }
    }

    value = props.cond;
  }

  // The values assigned to `x` are non-reactive, but the value of `x`
  // depends on the "control" variable `value` used as the switch test
  // condition. That variable is initially null on the first iteration
  // of the loop, but is later set to `props.value` which is reactive.
  // Therefore x should be treated as reactive.
  return [x];
}

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/reactive-control-dependency-reactive-after-fixpoint.js.
Where is Component() defined?
Component() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reactive-control-dependency-reactive-after-fixpoint.js at line 1.

Analyze Your Own Codebase

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

Try Supermodel Free