warning.js?6327:33警告:<provider>标记上的未知prop`store`。从元素中移除该道具

时间:2019-08-23 06:28:59

标签: reactjs react-redux react-router

在我的项目中,我试图合并两个化简器,但是每当我尝试使用CombineReducers({})合并它们时,我的道具就变得不确定,并且状态enter image description here(来自store.getState())变成是我的减速器的两个对象名称。查看我的减速机设置

enter image description here

[在此处输入图片描述] [2]

[2]:https://i.stack.imgur.com/rwXlF.png enter code here

1 个答案:

答案 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,

希望对某些人有用。