# Using Redux with React Error in Chapter 20?

**URL:** <https://forum.kirupa.com/t/using-redux-with-react-error-in-chapter-20/639456>\
**Category:** programming\
**Created:** [March 3, 2019, 1:44am UTC](https://forum.kirupa.com/t/using-redux-with-react-error-in-chapter-20/639456 "2019-03-03T01:44:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![overtureweb](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/overtureweb/32/9520_2.png) [@overtureweb](https://forum.kirupa.com/u/overtureweb)\
**Post date:** [March 3, 2019, 1:44am UTC](https://forum.kirupa.com/t/using-redux-with-react-error-in-chapter-20/639456/1 "2019-03-03T01:44:08Z")

</div>

First off, LOVE this book, it’s well written and the concepts are really easy to grasp. However I found an issue in Chapter 20 where we build a counter using Redux. On page 261 the switch block in the reducer is written as:

```
return { count: count + 1 }

```

But according to the Redux documentation the original state must be immutable. When declaring `var count = state.count` this is still a pointer to the original state and is changed in the switch block.

Wouldn’t it be better to write it as:  
`return Object.assign({}, state, {count: count + 1}`  
This creates a new state object and leaves the original intact so as not to violate the Redux rules of immutability.

Again, great book, super helpful!

---

<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 4, 2019, 6:30pm UTC](https://forum.kirupa.com/t/using-redux-with-react-error-in-chapter-20/639456/2 "2019-03-04T18:30:30Z")

</div>

That’s a good point, @overtureweb. I’ll mark this as something to fix in a future edition 🙂

Glad you are loving the the book!

Cheers,  
Kirupa
