You’ve been doing mapDispatchToProps wrong this entire time

Do this:
const mapDispatchToProps = {
decrement: () => ({ type: “DECREMENT" }),
increment: () => ({ type: "INCREMENT" })
};

instead of this:
const mapDispatchToProps = dispatch => {
return {
decrement: () => dispatch({ type: "DECREMENT" }),
increment: () => dispatch({ type: "INCREMENT" })
};
};

The difference is that we rely on react-redux to inject dispatch on each value that is a function in our mapDispatchToProps object, rather than relying on react-redux to inject dispatch into our mapDispatchToProps function.
If you are not effectively testing your code, then this is an easy way to increase code coverage, but it will also prevent bugs, because then you don’t have to worry about forwarding extra arguments.
For a working example on github, see this repo: https://github.com/mcrowder65/map-dispatch-to-props

Link: https://dev.to/mcrowder65/you-ve-been-doing-mapdispatchtoprops-wrong-this-entire-time-582m