Skip to content

Commit bbcbc59

Browse files
authored
Merge pull request #3876 from Nessworthy/patch-1
docs: Expand on cleanup behaviour for submission handlers
2 parents ec89b3a + 2e597c8 commit bbcbc59

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

docs/guides/form-submission.md

Lines changed: 13 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 the 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: _Call `setSubmitting(false)`_ to finish the cycle
2830

2931
## Frequently Asked Questions
3032

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

5759
</details>
60+
61+
<details>
62+
<summary>Why does `isSubmitting` remain true after submission?</summary>
63+
64+
If the submission handler returns a promise, make sure it is correctly resolved or rejected when called.
65+
66+
If the submission handler does not return a promise, make sure `setSubmitting(false)` is called at the end of the handler.
67+
68+
</details>

0 commit comments

Comments
 (0)