'Reset formik form?

I would like to reset a Formik form after it has been submitted so that the same form can be reused. I have seen various responses that clear the input with resetForm() but I would like to return the form to the same state that it was in before the first use. I see a number of methods on the form properties like resetForm and setTouched. So far I have been unable to reset the form to a 'prisitine' state. The main indicator is that the submit button is not greyed out as it should be since the second time around I would like the form to be completely cleared. It seems the field values are cleared with resetForm but there is something else that needs to be set to get the form in its original 'pristine' state. Any ideas?



Solution 1:[1]

you can define a state with your initial values and set formik values to it after submitting the form.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mohammad hosseini