Home / Function/ Component() — react Function Reference

Component() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  48daf08f_ac08_a82d_abce_e4530fc6be78["Component()"]
  3c09db17_5a08_ddd7_8324_9b0500676754["reactive-control-dependency-from-interleaved-reactivity-switch.js"]
  48daf08f_ac08_a82d_abce_e4530fc6be78 -->|defined in| 3c09db17_5a08_ddd7_8324_9b0500676754
  style 48daf08f_ac08_a82d_abce_e4530fc6be78 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reactive-control-dependency-from-interleaved-reactivity-switch.js lines 1–30

function Component(props) {
  // a and b are independent but their mutations are interleaved, so
  // they get grouped in a reactive scope. this means that a becomes
  // reactive since it will effectively re-evaluate based on a reactive
  // input
  const a = [];
  const b = [];
  b.push(props.cond);
  a.push(null);

  // Downstream consumer of a, which initially seems non-reactive except
  // that a becomes reactive, per above
  const c = [a];

  let x;
  switch (c[0][0]) {
    case true: {
      x = 1;
      break;
    }
    default: {
      x = 2;
    }
  }
  // The values assigned to `x` are non-reactive, but the value of `x`
  // depends on the "control" value `c[0]` which becomes reactive via
  // being interleaved with `b`.
  // Therefore x should be treated as reactive too.
  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-from-interleaved-reactivity-switch.js.
Where is Component() defined?
Component() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reactive-control-dependency-from-interleaved-reactivity-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