To submit a form in Formik, you need to somehow fire off the provided handleSubmit(e) or submitForm prop. When you call either of these methods, Formik will execute the following (pseudo code) each time:
initialValues are required and should always be specified. See #445isSubmitting to truesubmitCount + 1isValidating to truevalidate, and validationSchema asynchronously and deeply merge resultsisValidating to false, set errors, set isSubmitting to falseisValidating to false, proceed to "Submission"onSubmit or handleSubmit)setSubmitting to falsesetSubmitting(false) to finish the cycleIf isValidating is false and isSubmitting is true.
It is common practice to only show an input's errors in the UI if it has been visited (a.k.a "touched"). Before submitting a form, Formik touches all fields so that all errors that may have been hidden will now be visible.
Disable whatever is triggering submission if isSubmitting is true.
If isValidating is true and isSubmitting is true.
If the submission handler does not return a promise, make sure setSubmitting(false) is called at the end of the handler.
The latest Formik news, articles, and resources, sent to your inbox.