Redux-Form matchDispatchToProps not working

481 views Asked by At

when I try to pass my actions into the reduxForm call it doesn't map my actions to the props. I get this error:

Error Imaged 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);
    }
  }
1

There are 1 answers

1
Thaadikkaaran On BEST ANSWER

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 own redux-form connection as shown below.

class MyForm extends Component {}
MyForm = reduxForm(config)(MyForm)
MyForm = connect(mapStateToProps, mapDispatchToProps)(MyForm)
export default MyForm

Here is an example from redux-form doc.