gpt4 book ai didi

reactjs - this.props.dispatch 不是一个函数

转载 作者:行者123 更新时间:2023-12-03 14:04:32 24 4
gpt4 key购买 nike

当我尝试使用bindActionCreators时,我无法调用调度函数

调度功能不起作用:

@connect(state => ({oPurchaseDetails: state.cart.cartItems}), dispatch => bindActionCreators({updateItem}, dispatch))

如果我不使用bindActionCreators,updateItem 函数将不起作用。

updateItem 功能不起作用:

@connect(state => ({oPurchaseDetails: state.cart.cartItems}), dispatch => ({updateItem, dispatch}))

最佳答案

如果您提供mapDispatch函数,

connect只会自动插入this.props.dispatch。由于您使用的是自己的 mapDispatch,因此您有责任将其包含在返回值中。

参见http://redux.js.org/docs/faq/ReactRedux.html#react-props-dispatch了解更多详情。

关于reactjs - this.props.dispatch 不是一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40503885/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com