January 2020
Intermediate to advanced
470 pages
11h 13m
English
If mutating an object isn't allowed, then you must create a new object. For example, if you use Redux, a reducer is a function that receives the current state and an action (essentially, an object with new data) and produces the new state. Modifying the current state is totally forbidden and we could avoid this error by always working with frozen objects, as we saw in the previous section. To fulfill the reducer's requirements, we have to be able to clone the original state, as well as mutate it according to the received action. The resulting object will become the new state.
Read now
Unlock full access