Reputation: 83
I am working on pretty standard React/Redux/Redux-Saga style app.
I have Login form what using Formik. Inside onSubmit
I have action call loginUser()
. Saga take care of API call side effect and if there is error saga dispatch LOGIN_USER_ERROR
action what update store with this error.
So inside my Login component I now have mapped error prop from store saying for example Network error
.
My question is pretty simple: How to update Formik form after error prop is updated? Same question goes for un-general
server errrors like {'username': 'Already exists'}
. I need to show error feedback under input like when I was validating on client side before call.
Hope you will understand my problem. I think its understadable without demo code, but I can provide it if you don't understand me.
Upvotes: 3
Views: 1323
Reputation: 23957
Formik 2.x has initialErrors
prop, but in the meantime / current stable version I'd use the imperative setErrors
Upvotes: 1