【问题标题】:Warning: Failed prop type: The prop `createCourse` is marked as required in `CoursesPage`, but its value is `undefined`警告:失败的道具类型:道具`createCourse`在`CoursesPage`中被标记为必需,但其值为`undefined`
【发布时间】:2021-08-30 02:30:58
【问题描述】:

我的代码在没有mapDispatchToProps 函数的情况下工作,并且在handleSubmit 和CoursesPage.propTypes 处设置dispatch 函数而不是使用createCourse。我更新了CoursesPage.js 代码以使用mapDispatchToProps,但有些东西坏了。 This is my code at sandbox

【问题讨论】:

    标签: javascript reactjs redux react-redux


    【解决方案1】:

    你有两个问题:

    1. 您需要将mapDispatchToProps 传递给connect
    export default connect(mapStateToProps, mapDispatchToProps)(CoursesPage);
    
    1. createCourse 不是道具,而是您要导入的函数

    【讨论】:

      猜你喜欢
      • 2020-12-24
      • 2022-07-20
      • 2018-03-12
      • 2020-01-26
      • 2021-09-28
      • 1970-01-01
      • 1970-01-01
      • 2017-09-01
      • 1970-01-01
      相关资源
      最近更新 更多