jaredpalmer / formik

Build forms in React, without the tears 😭
https://formik.org
Apache License 2.0
34.02k stars 2.79k forks source link

submitForm doesn't get rejected if form is invalid #2380

Open alevkon opened 4 years ago

alevkon commented 4 years ago

🐛 Bug report

Current Behaviour

Calling submitForm() returns promise which is successfully resolves even if form is invalid.

Expected behaviour

Calling submitForm() should return rejected promise as the doc says: image

Suggested solution(s)

Probably return Promise.reject() or throw an error here: https://github.com/jaredpalmer/formik/blob/master/packages/formik/src/Formik.tsx#L797

Your environment

Software Version(s)
Formik 2.1.4
React 16.8.5
TypeScript 3.5.2
Browser chrome
npm/Yarn npm 6.4.1
Operating System MacOS Catalina
coreyar commented 4 years ago

Do you have a reproducible example?

archansel commented 4 years ago

Hi, I got the same behavior. Take a look at this example https://codesandbox.io/s/elegant-star-0ru0y

archansel commented 4 years ago

And another thing, is it possible to include the form values in resolve function? my current case, I have to get the form values (if valid) from submitForm()

archansel commented 4 years ago

And I think its duplicate of #2249

artursvonda commented 4 years ago

Unstale :)