allow-ref-access-in-async-event-handler-wrapper.tsx — react Source File
Architecture documentation for allow-ref-access-in-async-event-handler-wrapper.tsx, a tsx file in the react codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 534e28da_639e_38a4_87f5_7ee7fa119cde["allow-ref-access-in-async-event-handler-wrapper.tsx"] ac587885_e294_a1e9_b13f_5e7b920fdb42["react"] 534e28da_639e_38a4_87f5_7ee7fa119cde --> ac587885_e294_a1e9_b13f_5e7b920fdb42 style 534e28da_639e_38a4_87f5_7ee7fa119cde fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
// @enableInferEventHandlers
import {useRef} from 'react';
// Simulates react-hook-form's handleSubmit
function handleSubmit<T>(callback: (data: T) => void | Promise<void>) {
return (event: any) => {
event.preventDefault();
callback({} as T);
};
}
// Simulates an upload function
async function upload(file: any): Promise<{blob: {url: string}}> {
return {blob: {url: 'https://example.com/file.jpg'}};
}
interface SignatureRef {
toFile(): any;
}
function Component() {
const ref = useRef<SignatureRef>(null);
const onSubmit = async (value: any) => {
// This should be allowed: accessing ref.current in an async event handler
// that's wrapped and passed to onSubmit prop
let sigUrl: string;
if (value.hasSignature) {
const {blob} = await upload(ref.current?.toFile());
sigUrl = blob?.url || '';
} else {
sigUrl = value.signature;
}
console.log('Signature URL:', sigUrl);
};
return (
<form onSubmit={handleSubmit(onSubmit)}>
<input type="text" name="signature" />
<button type="submit">Submit</button>
</form>
);
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{}],
};
Domain
Subdomains
Functions
Types
Dependencies
- react
Source
Frequently Asked Questions
What does allow-ref-access-in-async-event-handler-wrapper.tsx do?
allow-ref-access-in-async-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-async-event-handler-wrapper.tsx?
allow-ref-access-in-async-event-handler-wrapper.tsx defines 3 function(s): Component, handleSubmit, upload.
What does allow-ref-access-in-async-event-handler-wrapper.tsx depend on?
allow-ref-access-in-async-event-handler-wrapper.tsx imports 1 module(s): react.
Where is allow-ref-access-in-async-event-handler-wrapper.tsx in the architecture?
allow-ref-access-in-async-event-handler-wrapper.tsx is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/allow-ref-access-in-async-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