...

/

Returning the State from the Reducer

Returning the State from the Reducer

A reducer should never be allowed to alter the state of the app. We'll see the correct way to handle the state below.

We'll cover the following...

When returning state from reducers, there’s something that may put you off at first.

However, if you already write good ReactJS code , then you should be familiar with this already:

You should not mutate the state received in your Reducer. Instead, you should always return a new copy of the state.

Technically, you should never do this:

Access this course and 1400+ top-rated courses and projects.