SET_SUBMIT_SUCCEEDED called from empty onSubmit and after stopSubmit with errors
See original GitHub issueI’m not returning a Promise from my onSubmit
, instead dispatching an action to be later picked up in a saga.
The saga calls, startSubmit('formName')
, and then at some point later calling stopSubmit('formName', errors)
(or just stopSubmit('formName')
if everything was ok).
In the case of a failure, the errors
are being properly picked up and applied to the form, however, I’m seeing the @@redux-form/SET_SUBMIT_SUCCEEDED
action coming through as well, which results in an inconsistent form state. The submit failed, but @@redux-form/SET_SUBMIT_SUCCEEDED
is setting submitSucceeded
to true even though I signalled a failed submission.
I’m trying to signal a failure, but the action sequence I’m getting is,
What’s more, I get the @@redux-form/SET_SUBMIT_SUCCEEDED
action creeping in even if I do nothing at all in onSubmit
, i.e. with an empty onSubmit
function that does nothing and doesn’t even return a Promise I see the following action,
In terms of correctness, correct me if I’m wrong, but I feel like this action shouldn’t be being called after an empty onSubmit
that doesn’t return a Promise. In that case shouldn’t nothing have happened? A Promise wasn’t returned, and startSubmit()
wasn’t called so why is Redux Form flipping submitSucceeded
to true
?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:41 (8 by maintainers)
Top GitHub Comments
Proposal
A new function, like
handleSubmit
, calleddispatchSubmit
, that you use like this:It will check that sync validation and async validation all passes, and if and only if the form is valid, it will dispatch an action that looks something like:
The
redux-form
reducer will ignore this action entirely. It will be up to all your fancy async middlewares to dispatchstartSubmit()
,stopSubmit()
, etc. to update the form’s submitting state manually.Would that satisfy everyone’s needs?
@erikras This looks interesting, though still feels a lot like hack and adds complexity. If there is still interest, I might get a PR going for the
dispatchSubmit
.