Redux: 嵌套的CombineReducers是个好主意吗?

创建于 2015-09-16  ·  3评论  ·  资料来源: reduxjs/redux

可以将CombineReducer嵌套,还是应该使用一次将所有的reducer合并为一个?
通过在每个步骤上组合化简器来创建存储树结构的方法不好吗?

或者,也许还有其他方法可以保持根存储的整洁(以免将所有树叶都放在根存储中)
伪代码结构示例:

rootReducer = combineReducers({
  router, // redux-react-router reducer
    account: combineReducers({
      profile: combineReducers({
         info, // reducer function
         credentials // reducer function
      }),
      billing // reducer function
    }),
    // ... other combineReducers
  })
});
question

最有用的评论

当然,这是个好主意。

所有3条评论

当然,这是个好主意。

您好,我在Multiple CombineReducer中实现了,

// schoolReducer.js

export default combineReducers({
  company: companyReducer,
  profile: profileReducer,
});

// studentInfo.js

export default combineReducers({
  student: studentReducer,
  course: courseReducer,
});

//rootReducer.js

export default combineReducers({
  school: schoolReducer,
  student: studentInfo,
});

有错误

Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.

@ justinlazaro-ubidy:
这是一个错误跟踪器,而不是支持系统。 对于使用方面的问题,请使用Stack Overflow或Reactiflux,那里有很多人愿意帮助您-您可能会更快地得到更好的答案。 谢谢!

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

jimbolla picture jimbolla  ·  3评论

cloudfroster picture cloudfroster  ·  3评论

mickeyreiss-visor picture mickeyreiss-visor  ·  3评论

CellOcean picture CellOcean  ·  3评论

captbaritone picture captbaritone  ·  3评论