After form is submitted, isSubmitting is not set to false
Submit form
isSubmitting should be set to false
CodeSandbox Link:
https://codesandbox.io/s/vqjmnkvjn7
This should be already fixed in #736, this issue is a placeholder so that I don't forget about it
Will cut a release
Fixed in beta.5
Awesome!
Still an issue
Formik Version: 1.4.2
+1 here, seeing the same issue
Formik version: 1.4.0
+1 here, seeing the same issue
Formik version: 1.5.0
Same on last version
+1 still an issue. Had to add a prop to check if errors were returned
+1 still an issue Hotfix
onSubmit={(values, actions) => {
setTimeout(() => {
alert(JSON.stringify(values));
// you have to clean up
actions.setSubmitting(false);
}, 500);
}}
@ahtashamabbasse setSubmitting(false) is required when not using async/promises. If you don't want to use setSubmitting, you can return a promise or use an async function. Without this requirement, Formik would never know when your timeout was complete, and would setSubmitting(false) immediately.
<Formik onSubmit={values =>
new Promise(resolve =>
setTimeout(() => {
alert(JSON.stringify(values));
resolve();
}, 500);
} />
This seems like a surprising default- I would've expected it to set isSubmitting to false immediately if supplying a synchronous function.
@dpikt agreed, should probably change it in a future major version. It seems like a backwards compatibility thing.
Still problem in version 2.1.4.
It works when I use async await.
onSubmit={async values => {
await new Promise(resolve => setTimeout(resolve, 500));
console.log(values)
}}
but doesn't work on callback.
onSubmit={values => {
setTimeout(() => {
console.log(values)
}, 500);
}}
Most helpful comment
+1 still an issue. Had to add a prop to check if errors were returned