我的代码在没有mapDispatchToProps
函数的情况下工作,并在handlessubmit和CoursesPage.propTypes
设置dispatch
函数,而不是使用createCourse
。为了使用mapDispatchToProps
,我更新了CoursesPage.js
代码,有些东西已经坏了。这是我在sandbox
你有两个问题:
- 您需要将
mapDispatchToProps
传递给connect
export default connect(mapStateToProps, mapDispatchToProps)(CoursesPage);
createCourse
不是道具,它是你要导入的函数