Replies: 1 comment
-
|
You're correct — What's happeningThe Fix optionsOption 1: Suppress the specific lint error (quickest) const onSubmit: SubmitHandler<ReceiptFormInput> = async (value) => {
let sigUrl: string;
if (sig) {
// eslint-disable-next-line react-compiler/react-compiler
const { blob } = await upload(ref.current?.toFile());
sigUrl = blob?.url || '';
}
// ...
};Option 2: Extract the ref read to a callback (cleanest) Move the ref access into a const getSignatureFile = useCallback(() => {
return ref.current?.toFile();
}, []);
const onSubmit: SubmitHandler<ReceiptFormInput> = async (value) => {
if (sig) {
const { blob } = await upload(getSignatureFile());
sigUrl = blob?.url || '';
}
};This is the pattern the React Compiler is designed for — imperative ref reads wrapped in callbacks, not inline in handlers. Option 3: Disable the rule for the file if you get many false positives /* eslint-disable react-compiler/react-compiler */Why the rule fires here but not alwaysThe React Compiler's lint rule does static analysis and flags |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
A linting error I am getting-
Here is the component-
I am not calling ref during render time. Its on a
onSubmithandler. Is onSubmit will call render time.Beta Was this translation helpful? Give feedback.
All reactions