Skip to content
Discussion options

You must be logged in to vote

I found the solution! This is not a bug, there is a correct solution. Only the 4th solution I've tried actually works out. Here is a codesandbox link: https://codesandbox.io/s/react-hook-form-reset-bug-resolved-lfp4w3?file=/src/index.tsx.

In a nutshell, you should use useEffect + isSubmitSuccessful formState flag to completely reset the form:

const form = useForm();
const {
  // ...
  reset,
  formState: { isSubmitSuccessful }
} = form;
React.useEffect(() => {
  if (isSubmitSuccessful) {
    reset();
  }
}, [isSubmitSuccessful, reset]);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by putnikproj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #10725 on July 29, 2023 22:26.