# redux react chapter 20

**URL:** <https://forum.kirupa.com/t/redux-react-chapter-20/642166>\
**Category:** programming\
**Created:** [March 21, 2020, 10:59am UTC](https://forum.kirupa.com/t/redux-react-chapter-20/642166 "2020-03-21T10:59:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![russelldavidson](https://avatars.discourse-cdn.com/v4/letter/r/b38774/32.png) [@russelldavidson](https://forum.kirupa.com/u/russelldavidson)\
**Post date:** [March 21, 2020, 10:59am UTC](https://forum.kirupa.com/t/redux-react-chapter-20/642166/1 "2020-03-21T10:59:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [March 21, 2020, 7:50pm UTC](https://forum.kirupa.com/t/redux-react-chapter-20/642166/2 "2020-03-21T19:50:15Z")

</div>

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 🙂

Glad you liked the book!
