Home / Function/ Component() — react Function Reference

Component() — react Function Reference

Architecture documentation for the Component() function in reactive-control-dependency-via-mutation-switch.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  4ea3a7d0_766c_7958_ac11_803ae371b3b8["Component()"]
  5b58170f_5d78_8815_c558_0523c68c9cca["reactive-control-dependency-via-mutation-switch.js"]
  4ea3a7d0_766c_7958_ac11_803ae371b3b8 -->|defined in| 5b58170f_5d78_8815_c558_0523c68c9cca
  style 4ea3a7d0_766c_7958_ac11_803ae371b3b8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reactive-control-dependency-via-mutation-switch.js lines 1–18

function Component(props) {
  // x is mutated conditionally based on a reactive value,
  // so it needs to be considered reactive
  let x = [];
  if (props.cond) {
    x.push(1);
  }
  // Since x is reactive, y is now reactively controlled too:
  let y = false;
  switch (x[0]) {
    case 1: {
      y = true;
      break;
    }
  }
  // Thus this value should be reactive on `y`:
  return [y];
}

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

Analyze Your Own Codebase

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

Try Supermodel Free