redux react chapter 20

In the file App.js used in Chapter 20 of “Learning React”, I get an error in the function mapDispatchToProps, because, in strict mode, functions can be defined only at top level or immediately in a function. It took me a while to figure out how to get around this constraint. What works is this:

function mapDispatchToProps(dispatch)
function funcinc() { return dispatch(increaseAction); }
function funcdec() { return dispatch(decreaseAction); }
var ret =
increaseCount: funcinc,
decreaseCount: funcdec
return ret;

This book explains things really well. Thanks

1 Like

Thanks for pointing this out @russelldavidson! I will take a look at why this error is happening and add this as a note to the errata page :slight_smile:

Glad you liked the book!