Home / Function/ Component() — react Function Reference

Component() — react Function Reference

Architecture documentation for the Component() function in usestate-derived-from-prop-no-show-in-data-flow-tree.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  78eb9150_46ce_c53b_928f_23289e51f42e["Component()"]
  456e7952_0119_c3c2_c099_7cfe4c450b97["usestate-derived-from-prop-no-show-in-data-flow-tree.js"]
  78eb9150_46ce_c53b_928f_23289e51f42e -->|defined in| 456e7952_0119_c3c2_c099_7cfe4c450b97
  style 78eb9150_46ce_c53b_928f_23289e51f42e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/effect-derived-computations/usestate-derived-from-prop-no-show-in-data-flow-tree.js lines 3–18

function Component({prop}) {
  const [s, setS] = useState();
  const [second, setSecond] = useState(prop);

  /*
   * `second` is a source of state. It will inherit the value of `prop` in
   * the first render, but after that it will no longer be updated when
   * `prop` changes. So we shouldn't consider `second` as being derived from
   * `prop`
   */
  useEffect(() => {
    setS(second);
  }, [second]);

  return <div>{s}</div>;
}

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/effect-derived-computations/usestate-derived-from-prop-no-show-in-data-flow-tree.js.
Where is Component() defined?
Component() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/effect-derived-computations/usestate-derived-from-prop-no-show-in-data-flow-tree.js at line 3.

Analyze Your Own Codebase

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

Try Supermodel Free