--- title: Wrap Async Submit Handlers in try/catch and Reset on isSubmitSuccessful impact: HIGH impactDescription: prevents stuck isSubmitting state and missing post-success reset tags: formstate, isSubmitting, isSubmitSuccessful, async, submit, reset --- ## Wrap Async Submit Handlers in try/catch and Reset on isSubmitSuccessful `isSubmitting` is the canonical way to disable the submit button while a request is in flight, but it has a well-known footgun: if your submit handler **throws**, `isSubmitting` stays `true` and the form becomes unrecoverable. Always `try/catch` inside the async handler. Pair this with `isSubmitSuccessful` + `useEffect(reset)` to clear the form after a successful submit (resetting inside the handler races with the success state transition). **Incorrect (throw leaves isSubmitting stuck; manual reset races):** ```typescript function CreatePostForm() { const { register, handleSubmit, reset, formState: { isSubmitting } } = useForm() const onSubmit = async (data: PostFormData) => { const res = await fetch('/api/posts', { method: 'POST', body: JSON.stringify(data) }) if (!res.ok) throw new Error('Save failed') // isSubmitting will stay true forever reset() // Races with the form's success state } return (