在我的项目中,我试图合并两个化简器,但是每当我尝试使用CombineReducers({})合并它们时,我的道具就变得不确定,并且状态enter image description here(来自store.getState())变成是我的减速器的两个对象名称。查看我的减速机设置
[在此处输入图片描述] [2]
[2]:https://i.stack.imgur.com/rwXlF.png enter code here
答案 0 :(得分:0)
尽管未包括所有必需的代码,但我怀疑该错误是由错误的mapStateToProps
函数引起的。我遇到了类似的问题,并花了一些时间调查这个问题。正确的方法是在使用combineReducers
并重构以下部分以包含适当的reducer之后立即进行:
export default combineReducers({
example: exampleReducer,
second: secondReducer
});
在这里必须对示例进行相应调整,以使道具运行顺畅。
function mapStateToProps(state) {
return {
ads: state.example.ads,
quizes: state.example.quizes
};
}
关键时刻是ads: state.ads,
变成ads: state.example.ads,
希望对某些人有用。