I'm using submitFields to set errors for individual fields. But when an error doesn't match any field, I want to set the error in the errors in the form's errors field.
here's a part of the code I tried (see codepen for full version)
const login$Q = () => {
return new Promise((resolve, reject) => {
setTimeout(() => reject('show this in errors field of user'), 500)
})
}
const loginActionAsync = () => (dispatch) => {
return login$Q().catch(err => {
dispatch(actions.setErrors('user', err))
})
}
const { dispatch } = this.props
dispatch(actions.submitField('user', dispatch(loginActionAsync)))
But it doesn't seem to work. May if it's I didn't do it correctly or it's not possible to do?
The Problem
I'm using
submitFields
to set errors for individual fields. But when an error doesn't match any field, I want to set the error in theerrors
in the form's errors field.here's a part of the code I tried (see codepen for full version)
But it doesn't seem to work. May if it's I didn't do it correctly or it's not possible to do?
Steps to Reproduce
https://codepen.io/zzhjerrygit/pen/gXQjGr?editors=0011
Expected Behavior
I'm able to use
setError
after the async call finishesActual Behavior
I cannot use
setError
after the async call finishesReproducible Code Example
https://codepen.io/zzhjerrygit/pen/gXQjGr?editors=0011