Skip to content

Commit

Permalink
Merge pull request #3876 from Nessworthy/patch-1
Browse files Browse the repository at this point in the history
docs: Expand on cleanup behaviour for submission handlers
  • Loading branch information
quantizor committed Sep 11, 2023
2 parents ec89b3a + 2e597c8 commit bbcbc59
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions docs/guides/form-submission.md
Expand Up @@ -23,8 +23,10 @@ To submit a form in Formik, you need to somehow fire off the provided `handleSub

### Submission

- Proceed with running your submission handler (i.e.`onSubmit` or `handleSubmit`)
- _you call `setSubmitting(false)`_ in your handler to finish the cycle
- Proceed with running the submission handler (i.e. `onSubmit` or `handleSubmit`)
- Did the submit handler return a promise?
- Yes: Wait until it is resolved or rejected, then set `setSubmitting` to `false`
- No: _Call `setSubmitting(false)`_ to finish the cycle

## Frequently Asked Questions

Expand Down Expand Up @@ -55,3 +57,12 @@ Disable whatever is triggering submission if `isSubmitting` is `true`.
If `isValidating` is `true` and `isSubmitting` is `true`.

</details>

<details>
<summary>Why does `isSubmitting` remain true after submission?</summary>

If the submission handler returns a promise, make sure it is correctly resolved or rejected when called.

If the submission handler does not return a promise, make sure `setSubmitting(false)` is called at the end of the handler.

</details>

0 comments on commit bbcbc59

Please sign in to comment.