I have a form built with Formik. And I would like to reset/ empty it after submit. I've tried to add resetForm(), but it's not working. Here is my code:
onSubmit={(values, { setSubmitting, resetForm }) => {
setTimeout(() => {
alert(JSON.stringify(values, null, 2));
setSubmitting(false);
resetForm();
}, 400);
}}
And a live example https://codesandbox.io/s/reset-form-8sw24.
Where is my mistake and how can I reset/ empty form onSubmit?
I had to add value={values.phone} to the input as I'm using a custom input. After that resetForm() is working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With