Redux is a predictable state container for JavaScript apps.
Redux homepage
state
tree of Redux is readonly.Modification is only possible by dispatching an action. Reducers are the only functions that can change the state tree.
To describe a state mutation requires a function (reducer) is taking the previous state, the action being dispatched and returns the next state.
The function has to be a pure function. A pure function returns a value that is solely referring to the value that it gets as their arguments.
/* pure */
function square(x) {
return x * x;
}
/* impure */
function square(x) {
updateXinSquare(x);
return x * x;
}