I'm aware that if you throw a SubmissionError
from your handleSubmit()
function, the redux-form
code will fill in the errors of the appropriate fields and/or the form itself.
Yet that API of setting field/form errors, tightly couples our implementation of handleSumbit()
to be a caller of the redux-form
code (which contains the SubmissionError
exception handler).
My use case is to have something like so:
function asyncActionDispatcher(values) {
return (dispatch, getState) => {
// I'm using getState, which is not accessible in handleSubmit()
// But I'd also like to be able to set errors on the form fields and/or the
// form.
};
}
function handleSubmit(values, dispatch) {
dispatch(
asyncActionDispatcher(values)
);
}
I can't throw a SubmissionError
in asyncActionDispatcher()
because it's called by redux
and not redux-form
.
Does redux-form
have another API to set errors on fields/form?
validate
andasyncValidate
still seem to require the same caller/callee coupling as I mentioned and neither provide you withgetState()
, in order to always get the latest state values. – Wormwood