Mis-Used Promise ESLINT

Anyone know how to correct this without telling Eslint to ignore? <form // eslint-disable-next-line @typescript-eslint/no-misused-promises onSubmit={methods.handleSubmit(async (values) => { await mutation.mutateAsync(values); methods.reset(); })} className="space-y-2" > I can't tell the onSubmit that handleSubmit is void because then the validation doesn't take place.
3 Replies
JulieCezar
JulieCezar13mo ago
Maybe try to extract the method before that and type it out?
const myMethod: () => void = methods.handleSubmit;

or

const myMethod = methods.handleSubmit as () => void ;
const myMethod: () => void = methods.handleSubmit;

or

const myMethod = methods.handleSubmit as () => void ;
iDarkLightning
iDarkLightning13mo ago
Well handle the promise properly then catch
whatplan
whatplan13mo ago
this or onClick={() => void functionWithPromise()}
Want results from more Discord servers?
Add your server
More Posts