I'm new to Redux and trying to figure out why the props throw an error when i have binded it with the matchDispatchToProps function. Shouldn't BindActionCreators already be binding the functions?
import ContactForm from '../containers/ContactForm';
import React, { Component } from 'react';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {handleSubmit} from '../actions/index'
class ContactPage extends Component {
submit(values) {
this.props.handleSubmit(values) //ERROR
}
render() {
return (
<ContactForm onSubmit={this.submit} />
);
}
}
function mapStateToProps(state) {
return {
contacts: state.users
};
}
// Get actions and pass them as props to to UserList
// > now UserList has this.props.selectUser
function matchDispatchToProps(dispatch){
return bindActionCreators({handleSubmit: handleSubmit}, dispatch);
}
// We don't want to return the plain UserList (component) anymore, we want to return the smart Container
// > UserList is now aware of state and actions
export default connect(mapStateToProps, matchDispatchToProps)(ContactPage);