【问题标题】:React js et Redux display data Error: Invalid value of type object for mergePropsReact js et Redux 显示数据错误:mergeProps 类型对象的值无效
【发布时间】:2020-03-31 21:32:27
【问题描述】:

我得到的错误如下:

Error: Invalid value of type object for mergeProps argument when connecting component Majregion.

我是 redux 新手,尝试过各种不同的方法。

Majregion.propTypes   = {
  addRegionMaj : PropTypes.func.isRequired,
  errors : PropTypes.object.isRequired


}

const mapStateToProps = state =>({
  errors : state.errors,
  Region : state.Region,

})



export default connect (mapStateToProps,{getBackLog} ,{addRegionMaj}) (Majregion);


export const getBackLog = () => async dispatch => {

    const res = await axios.get("http://localhost:8080/regions/all")

    dispatch ({
        type : GET_MODELS_REGION,
        payload : res.data
    });


};

注意:一切正常,就在我在导出默认连接中添加方法 {getBackLog} 时 请问我该怎么办

【问题讨论】:

    标签: reactjs redux react-redux state


    【解决方案1】:

    我认为你应该这样做:

    export default connect (mapStateToProps,{ getBackLog ,addRegionMaj }) (Majregion);
    

    【讨论】:

      猜你喜欢
      • 2019-02-24
      • 2018-04-28
      • 2021-02-07
      • 2021-02-28
      • 2019-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多