redux-form: throw new SubmissionError() causing Uncaught (in promise) error.
Hello! I am using Redux Thunk and React Form to do submission validations against my signup form. I want the errors returned by my API endpoint to appear inline in my form. Hence why I need SubmissionError. Everything works great without throwing a new submission error, the form does exactly what I need it to do. The problem is, when I put in the single line to throw new SubmissionError() I get the following error:

Here is my Action creator (using Redux Thunk):
import axios from 'axios';
import { browserHistory } from 'react-router';
import { CTAButtonUnload } from '../../buttons/CTAButton/CTAButtonUnload'
import { SubmissionError } from 'redux-form'
const ROOT_URL = 'XXXXXXXXXXXXXX';
export const signupUser = (formData) => {
return function(dispatch) {
axios.post(ROOT_URL + '/v1/user', {
firstName: formData.firstName,
lastName: formData.lastName,
email: formData.email,
password: formData.password
})
.then(response => {
dispatch({
type: 'CTAButtonUnload',
payload: {
hover: false,
click: false,
loading: false
}
})
browserHistory.push('/signup/workspace');
})
.catch(response => {
if(response.response.data.code == 403){
throw new SubmissionError({email: null, _error: response.response.data.description})
}
dispatch({
type: 'CTAButtonUnload',
payload: {
hover: false,
click: false,
loading: false
}
})
});
}
}
Could this error be caused by a promise inside of SubmissionError()? I saw that others have had similar problems with this error, but they look to be using the Async validation option, I am not, so I am wondering if I am doing something wrong or if this is something with reduxForm?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 21
- Comments: 17 (1 by maintainers)
I encountered a similar problem and managed to fix this by adding a return on the submit handler.
from
to
I’m calling
handleSignup()from my redux form component:I had some progress on this one. As it turned out, I was using
redux-form/immutableall over my code, except when importingSubmissionForm, I did:But if you are using
redux-form/immutable, you need to use:Apparently they are two different classes.
@JensenTStava In your
mapDispatchToPropsyou should have this format:Just updated to
webpack 2, and started encountering this bug.In my case, the issue is not from
redux-formbutwebpack 2and / orbabel.My code breaks if I imported
SubmissionErrorlike this:But works if I import it like this:
I was able to figure out this line does
error instanceof SubmissionErrorand returning false.It lead me to believe somehow
webpack 2is generated two copiesSubmissionErrors…Update:
Created a simple demonstration for this:
https://github.com/aq1018/webpack2-redux-form-submission-error-weirdness
I was stuck for one day with similar Error. I was returning all promises in Project and I still couldn’t figure it out. Then I ran into this https://stackoverflow.com/questions/38481857/getting-cannot-call-a-class-as-a-function-in-my-react-project
I was using react router 4 like this:
<Route exact path="/events/checkout/:id/" render={(props) => <CheckoutContainer {...props} />} />} />then I change it into this:
<Route exact path="/events/checkout/:id/" component={(props) => <CheckoutContainer {...props} />} />} />So, I just changed
rendertocomponentand It is working! Problem is thatrendermost likely treat all components as functional.For me this issue was caused by not adding a return declaration before my ajax call. So instead of
axios.post(URL, payload)I had to make surereturn axios.post(URL, payload)was used. Thethrow new SubmissionError(…)call was in the.catch( error => …block of the axios call.@JensenTStava I was under the impression that ‘mapsDispatchToProps’ was only for version 5 and older.
I would love to see a solution to this issue because I am having a similar problem as the OP.
@francosioquim your solution was it. The
handleSubmitfunction thatredux-formdefines probably look (conceptually) something like this:I’m abstracting away a lot, but the idea is that
handleSubmitfunction will only work if theuserDefinedSubmitfunction returns athenable. Thank you!