In React, we are dealing with three core concepts, which we have already introduced the state, the action, and the reducer. Now, let's dive in deeper and really get a sense of how they fit together and how they work.
Core concepts
Immutability patterns
The whole point of the state is to take an existing state, apply an action to it, and produce a new state. It can be written like this:
old state + action = new state
Imagine, if you were performing basic calculations, then you would start writing it like this:
// sum is 0
let sum = 0;
// sum is now 3
sum +=3;
The Redux way of doing things, though, is to change the preceding to:
let sum = 0;
let sumWith3 = sum + 3;
let sumWith6 = sumWith3 + 3;
We don't mutate anything...