Form errors object doesn't get updated after running validateForm, looks like it updates asynchronously and I can't access it where needed inside handler.
Current Behavior
Leave the First Name empty and click Va li date, you'll see an alert with empty errors . errors are undefined after running validateForm, they get updated eventually, but I can't access them right after validation.
Expected behavior
errors are set after validation, the alert shows errors
Bug report
Form
errors
object doesn't get updated after runningvalidateForm
, looks like it updates asynchronously and I can't access it where needed inside handler.Current Behavior
Leave the
First Name
empty and clickVa li date
, you'll see an alert with empty errors .errors
are undefined after runningvalidateForm
, they get updated eventually, but I can't access them right after validation.Expected behavior
errors
are set after validation, the alert shows errorsReproducible example
https://codesandbox.io/s/charming-wave-g8tgz3?file=/index.js
Suggested solution(s)
Maybe there's a workaround to access the errors after validation? I need to know if validation failed inside my handler function.
Additional context
I use
validatilnSchema
andyup
to run validation.