Calling reset() in React Hook Form's onSubmit leaves submission state behind
A developer found that calling reset() inside an onSubmit handler clears the form values but not the submission state. React Hook Form's handleSubmit writes isSubmitted, isSubmitSuccessful and submitCount back after the handler finishes, which makes validation errors appear while the user is typing in the fresh form. Testing with React 19, react-hook-form 7.91 and zod confirmed the problem, and async handlers made no difference. The author found submitCount is also unreliable with this approach, though errors still cleared correctly once fixed. The suggested fix is to move the reset into a useEffect that watches isSubmitSuccessful, as shown in the React Hook Form docs.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in