Home / Function/ Component() — react Function Reference

Component() — react Function Reference

Architecture documentation for the Component() function in allow-ref-access-in-event-handler-wrapper.tsx from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  fda2edbb_a7ac_023c_bca0_677a0fcd43e7["Component()"]
  3ea5530a_b1d5_cc11_a12a_f91f38ffdcb5["allow-ref-access-in-event-handler-wrapper.tsx"]
  fda2edbb_a7ac_023c_bca0_677a0fcd43e7 -->|defined in| 3ea5530a_b1d5_cc11_a12a_f91f38ffdcb5
  5aaa755f_c1b4_a154_511a_d6dc0ceb53b0["handleSubmit()"]
  fda2edbb_a7ac_023c_bca0_677a0fcd43e7 -->|calls| 5aaa755f_c1b4_a154_511a_d6dc0ceb53b0
  style fda2edbb_a7ac_023c_bca0_677a0fcd43e7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/allow-ref-access-in-event-handler-wrapper.tsx lines 12–31

function Component() {
  const ref = useRef<HTMLInputElement>(null);

  const onSubmit = (data: any) => {
    // This should be allowed: accessing ref.current in an event handler
    // that's wrapped by handleSubmit and passed to onSubmit prop
    if (ref.current !== null) {
      console.log(ref.current.value);
    }
  };

  return (
    <>
      <input ref={ref} />
      <form onSubmit={handleSubmit(onSubmit)}>
        <button type="submit">Submit</button>
      </form>
    </>
  );
}

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-event-handler-wrapper.tsx.
Where is Component() defined?
Component() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/allow-ref-access-in-event-handler-wrapper.tsx at line 12.
What does Component() call?
Component() calls 1 function(s): handleSubmit.

Analyze Your Own Codebase

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

Try Supermodel Free