Home / Function/ Component() — react Function Reference

Component() — react Function Reference

Architecture documentation for the Component() function in allow-ref-access-in-unused-callback-nested.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  4138b805_1da9_b6e4_6855_0561b25fe2b1["Component()"]
  a8c0b5dc_65f4_b7e1_7ac9_a0b7f993cd8a["allow-ref-access-in-unused-callback-nested.js"]
  4138b805_1da9_b6e4_6855_0561b25fe2b1 -->|defined in| a8c0b5dc_65f4_b7e1_7ac9_a0b7f993cd8a
  style 4138b805_1da9_b6e4_6855_0561b25fe2b1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/allow-ref-access-in-unused-callback-nested.js lines 4–21

function Component() {
  const ref = useRef(null);
  const [state, setState] = useState(false);
  useEffect(() => {
    const callback = () => {
      ref.current = 'Ok';
    };
  }, []);

  useEffect(() => {
    setState(true);
  }, []);

  // We use state to force a re-render and observe whether the
  // ref updated. This lets us check that the effect actually ran
  // and wasn't DCE'd
  return <Child key={String(state)} ref={ref} />;
}

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/allow-ref-access-in-unused-callback-nested.js.
Where is Component() defined?
Component() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/allow-ref-access-in-unused-callback-nested.js at line 4.

Analyze Your Own Codebase

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

Try Supermodel Free