Resetting the Form Data
Learn how to reset the form data with Formik.
We'll cover the following...
Often, we want to reset a form by returning its values to those set in initialValues
. This could be after we have successfully submitted the form or when the user clicks a “Reset” or “Clear” button.
With Formik, we can reset our form values to those values stated in initialValues
. We can also change the values in the next initialValues
object that our form will use.
Manually reset the form to initial values
We can reset our form at any point. We may decide to reset after a user clicks the “Reset” button, after the submission is complete, or after an event takes place. Whatever the case is, Formik provides a resetForm
method for this purpose. This method is available on the ...