I learn React Redux and reading here about using mapDispatchToProps
and bindActionCreators
It works fine the bindActionCreators
when using it alone like so:
export default connect(null, (dispatch) =>
bindActionCreators(actionCreators, dispatch)
)(FormContainer);
But I have more actions and tried this:
function mapDispatchToProps(dispatch) {
return {
bindActionCreators(actionCreators, dispatch),
clearPosts: () => dispatch(clearPosts()),
}
}
And that gives error like so:
. How can I combine them I read the docs and there's nothing as I can see about this please advice
try below code
function mapDispatchToProps(dispatch) {
return {
todoActions: bindActionCreators(actionCreators, dispatch),
clearPosts: () => dispatch(clearPosts()),
}
}