Home / Function/ Component() — react Function Reference

Component() — react Function Reference

Architecture documentation for the Component() function in todo-function-expression-captures-value-later-frozen.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  94d2fb46_baf6_edf5_938e_ad294cb0adaf["Component()"]
  f8117c3f_868e_0fbb_a167_44f42fcf8fd9["todo-function-expression-captures-value-later-frozen.js"]
  94d2fb46_baf6_edf5_938e_ad294cb0adaf -->|defined in| f8117c3f_868e_0fbb_a167_44f42fcf8fd9
  style 94d2fb46_baf6_edf5_938e_ad294cb0adaf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/todo-function-expression-captures-value-later-frozen.js lines 1–14

function Component(props) {
  let x = {};
  // onChange should be inferred as immutable, because the value
  // it captures (`x`) is frozen by the time the function is referenced
  const onChange = e => {
    maybeMutate(x, e.target.value);
  };
  if (props.cond) {
    <div>{x}</div>;
  }
  // ideally this call would be outside the memoization block for `x`
  onChange();
  return <Foo value={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/todo-function-expression-captures-value-later-frozen.js.
Where is Component() defined?
Component() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/todo-function-expression-captures-value-later-frozen.js at line 1.

Analyze Your Own Codebase

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

Try Supermodel Free