when I try to pass my actions into the reduxForm call it doesn't map my actions to the props. I get this error:
I've included the steps for error recreation below. Many thanks for your help!
My Test Action Creator with redux-thunk
export function signUpUser({ firstName, lastName, email, password, passwordConfirm }) {
console.log("action: ", firstName)
console.log("action: ", lastName)
console.log("action: ", email)
console.log("action: ", password)
console.log("action: ", passwordConfirm)
return function(dispatch) {
dispatch({
type: AUTH_USER,
payload: response.data.message
});
}
}
VSCode Method Signature Helper
(alias) reduxForm(config: ReduxFormConfig, mapStateToProps?: MapStateToProps, mapDispatchToProps?: MapDispatchToPropsFunction | MapDispatchToPropsObject): ClassDecorator
import reduxForm
My call to reduxForm
import { Field, reduxForm } from 'redux-form';
...
export default reduxForm({
form: 'authentication'
}, null, signUpUser)(Login);
My Usage of the action in my React.Component
handleFormSubmit(values) {
this.validateFields(values);
console.log("works")
if (this.state.errors.email.exists && this.state.errors.email.valid && this.state.errors.password.match) {
console.log("works2")
this.props.signUpUser(values);
}
}
If @Jyothi's comment did not work for you, then you might be using
redux-form
v6. In the version 6, you have to use your ownredux-form
connect
ion as shown below.Here is an example from
redux-form
doc.