Reactjs React-redux |我可以根据条件调用React-redux的连接方法吗

Reactjs React-redux |我可以根据条件调用React-redux的连接方法吗,reactjs,Reactjs,我有一个组件,我将品牌价值传递给组件作为 props,基于props值,组件调用不同的fecth API 方法的作用顺序分别为fecthOMOrder、fecthSVOrder。我需要 要在“连接”中指定相同条件,以下条件不起作用, 请提前告知,谢谢 if (this.props.brand=="OM") { export default connect(mapStateToProps,{fecthOMOrder})(OrderList); } else { export default co

我有一个组件,我将品牌价值传递给组件作为 props,基于props值,组件调用不同的fecth API 方法的作用顺序分别为fecthOMOrder、fecthSVOrder。我需要 要在“连接”中指定相同条件,以下条件不起作用, 请提前告知,谢谢

if (this.props.brand=="OM")
{
export default connect(mapStateToProps,{fecthOMOrder})(OrderList);

}
else
{
export default connect(mapStateToProps,{fecthSVOrder })(OrderList);

}

您还可以声明
mapDispatchToProps
,并使其具有条件

let mapDispatchToProps;
if (this.props.brand=="OM") {
  mapDispatchToProps = dispatch => {
    return {
      fecthOMOrder
    }
  }
}
else {
  mapDispatchToProps = dispatch => {
    return {
      fecthSVOrder
    }
  }
}
export default connect(mapStateToProps,mapDispatchToProps)(OrderList);

为什么不编写更通用的
fetchOrder
,并使用类似
fetchOrder('OM')
?。要么导入这两个函数,然后根据品牌条件调用相应的获取。谢谢,但我无法在课堂外访问我的this.props.brand(抱歉,我是新手),感谢您的帮助