Why Do We Need to Avoid Mutations?
Understand the need to avoid mutation.
We'll cover the following...
The most important thing about reducers in Redux is that they should never mutate the existing state. There are several functions in JavaScript that can help when working with immutable objects. Before we look at those, however, let’s consider why this is so important.
Reason
One of the reasons behind the immutability requirement for reducers is due to change detection. After the store
passes the current state
and action to the root reducer, it and various UI components
of the application need a way to determine what changes, if any, have happened to the global
...