使用React Router v4将Async减速器和Sagas加载到React-样板中

时间:2018-10-11 13:05:43

标签: reactjs react-redux react-router-v4 react-boilerplate

我正在考虑将项目迁移到最新的react-boilerplate版本,并且许多模块已更改。我无法在React Router v4上与我的reducer和sagas一起玩。我看着Dynamically load redux reducers with react router 4 我现在收到以下错误: 警告:React.createElement:类型无效-预期为字符串(对于内置组件)或类/函数(对于复合组件),但得到了:对象。

  

检查withReducer(Component)的渲染方法。       在withReducer(Component)中(由Route创建)       在途中(由App创建)       在Switch中(由App创建)       在div中(由App创建)       在App中(由Connect(App)创建)       在Connect(App)中(由Route创建)       在路由中(由withRouter(Connect(App))创建)       在withRouter(Connect(App))中       在路由器中(由BrowserRouter创建)       在BrowserRouter中       在IntlProvider中(由LanguageProvider创建)       在LanguageProvider中(由Connect(LanguageProvider)创建)       在Connect(LanguageProvider)中       在提供商中

我的代码与我跟随的示例略有不同,因为我要添加withRouter:

const withConnect = withRouter(connect(mapStateToProps, mapDispatchToProps));

const addHelpReducer = injectReducer({ key: 'help', reducer: helpReducer });

export default compose(
    addHelpReducer,
    withConnect
  )(Help);

injectReducer来自react-boilerplate utils文件,我尚未修改该文件或configureStore文件。

1 个答案:

答案 0 :(得分:0)

我想出了办法:

export default compose(
    withRouter,
    withReducer,
    withSaga,
    withConnect
  )(Help);

尽管我现在进入了另一个问题。关闭这个。

相关问题