Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Expand on cleanup behaviour for submission handlers #3876

Merged
merged 6 commits into from
Sep 11, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions docs/guides/form-submission.md
Original file line number Diff line number Diff line change
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 your submission handler (i.e. `onSubmit` or `handleSubmit`)
quantizor marked this conversation as resolved.
Show resolved Hide resolved
- Did the submit handler return a promise?
- Yes: Wait until it is resolved or rejected, then set `setSubmitting` to `false`
- No: _You call `setSubmitting(false)`_ in your handler to finish the cycle
quantizor marked this conversation as resolved.
Show resolved Hide resolved

## 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>
quantizor marked this conversation as resolved.
Show resolved Hide resolved

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>