handleSubmit doesn't return anything
See original GitHub issueAre you submitting a bug report or a feature request?
Kind-of both I guess.
What is the current behavior?
Calling handleSubmit
doesn’t return anything. According to the docs it should return a Promise in some cases. What cases, I have no idea. I have tried using an async function, submitting the form with invalid values, valid values, but it still doesn’t return anything in any of the cases.
This is really annoying when you want to reset the form after submitting it without errors. I ended up using the following code, but I have no idea if that’s the correct approach or not. Not trying to be annoying or anything, but how am I supposed as a user of this library to tell when handleSubmit
is synchronous and when asynchronous?
<Form<FormValues> onSubmit={onSubmit}>
{({ handleSubmit, form, valid }): ReactElement => (
<form
className="add-activity"
onSubmit={(event): void => {
handleSubmit(event);
if (valid) {
form.reset();
}
}}
>
What is the expected behavior?
I’d like to see the behavior of handleSubmit
standardized. It should either be always asynchronous and return a Promise, or it should be always synchronous and not return anything.
What’s your environment?
react final form 6.3.0, final form 4.18.5
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Published fix in
v6.3.4
.I used to use. Don’t forget that onSubmit must be async: