Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

this.props.dispatch is not a function

I'm unable to call dispatch function when I try to use bindActionCreators

Dispatch Function not working:

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

If I don't use bindActionCreators, updateItem function doesn't work.

updateItem Function not working:

@connect(state => ({oPurchaseDetails: state.cart.cartItems}), dispatch => ({updateItem, dispatch}))
like image 663
Muhammad Ateeq Azam Avatar asked Jul 25 '26 04:07

Muhammad Ateeq Azam


1 Answers

connect only inserts this.props.dispatch automatically if you do not supply a mapDispatch function. Because you're using your own mapDispatch, you are responsible for including that in the return value.

See http://redux.js.org/docs/faq/ReactRedux.html#react-props-dispatch for further details.

like image 98
markerikson Avatar answered Jul 27 '26 10:07

markerikson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!