mapDispatchToProps
parent
0fa1f83aa9
commit
3137dce047
|
@ -17,7 +17,7 @@ class CoursesPage extends React.Component {
|
||||||
|
|
||||||
handleSubmit = (event) => {
|
handleSubmit = (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.props.dispatch(courseActions.createCourse(this.state.course));
|
this.props.createCourse(this.state.course);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -40,7 +40,7 @@ class CoursesPage extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
CoursesPage.propTypes = {
|
CoursesPage.propTypes = {
|
||||||
dispatch: PropTypes.func.isRequired,
|
createCourse: PropTypes.func.isRequired,
|
||||||
courses: PropTypes.array.isRequired
|
courses: PropTypes.array.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -50,4 +50,10 @@ function mapStateToProps(state) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps)(CoursesPage);
|
function mapDispatchToProps(dispatch) {
|
||||||
|
return {
|
||||||
|
createCourse: (course) => dispatch(courseActions.createCourse(course))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapDispatchToProps)(CoursesPage);
|
||||||
|
|
Loading…
Reference in New Issue