Skip to content

Commit 07d8cc5

Browse files
authored
docs: Expand on cleanup behaviour for submission handlers
Cover use cases for both using a submission handler that returns a promise, and for a one which does not. Add FAQ entry about submission handler cleanup.
1 parent da58b29 commit 07d8cc5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

docs/guides/form-submission.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ To submit a form in Formik, you need to somehow fire off the provided `handleSub
2323

2424
### Submission
2525

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

2931
## Frequently Asked Questions
3032

@@ -55,3 +57,8 @@ Disable whatever is triggering submission if `isSubmitting` is `true`.
5557
If `isValidating` is `true` and `isSubmitting` is `true`.
5658

5759
</details>
60+
<summary>Why does `isSubmitting` remain `true` after submission?</summary>
61+
<details>
62+
If the submission handler is returning a promise, make sure the promise has resolved or rejected.
63+
If the submission handler is not returning a promise, make sure `setSubmitting(false)` is called at the end of the handler.
64+
</details>

0 commit comments

Comments
 (0)