I\'ve got a simple React component that I connect up (mapping a simple array/state over). To keep from referencing the context for store I\'d like a way to get \"dispatch\"
You can usually mix and match based on what you'd like.
You can pass dispatch
on as a prop if that is what you want:
export default connect(mapStateToProps, (dispatch) => ({
...bindActionCreators({fetchUsers}, dispatch), dispatch
}))(Users);
I'm not sure how fetchUsers
is used (as an async function?), but you would usually use something like bindActionCreators
to auto-bind dispatch and then you would not have to worry about using dispatch
directly in connected components.
Using dispatch
directory sort of couples the dumb, stateless component with redux. Which can make it less portable.