Home / File/ allow-ref-access-in-event-handler-wrapper.tsx — react Source File

allow-ref-access-in-event-handler-wrapper.tsx — react Source File

Architecture documentation for allow-ref-access-in-event-handler-wrapper.tsx, a tsx file in the react codebase. 1 imports, 0 dependents.

File tsx TestingUtilities Fixtures 1 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  3ea5530a_b1d5_cc11_a12a_f91f38ffdcb5["allow-ref-access-in-event-handler-wrapper.tsx"]
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  3ea5530a_b1d5_cc11_a12a_f91f38ffdcb5 --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  style 3ea5530a_b1d5_cc11_a12a_f91f38ffdcb5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// @enableInferEventHandlers
import {useRef} from 'react';

// Simulates react-hook-form's handleSubmit or similar event handler wrappers
function handleSubmit<T>(callback: (data: T) => void) {
  return (event: any) => {
    event.preventDefault();
    callback({} as T);
  };
}

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>
    </>
  );
}

export const FIXTURE_ENTRYPOINT = {
  fn: Component,
  params: [{}],
};

Subdomains

Dependencies

  • react

Frequently Asked Questions

What does allow-ref-access-in-event-handler-wrapper.tsx do?
allow-ref-access-in-event-handler-wrapper.tsx is a source file in the react codebase, written in tsx. It belongs to the TestingUtilities domain, Fixtures subdomain.
What functions are defined in allow-ref-access-in-event-handler-wrapper.tsx?
allow-ref-access-in-event-handler-wrapper.tsx defines 2 function(s): Component, handleSubmit.
What does allow-ref-access-in-event-handler-wrapper.tsx depend on?
allow-ref-access-in-event-handler-wrapper.tsx imports 1 module(s): react.
Where is allow-ref-access-in-event-handler-wrapper.tsx in the architecture?
allow-ref-access-in-event-handler-wrapper.tsx is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/allow-ref-access-in-event-handler-wrapper.tsx (domain: TestingUtilities, subdomain: Fixtures, directory: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler).

Analyze Your Own Codebase

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

Try Supermodel Free