Redux is a predictable state container for JavaScript applications. It allows developers to manage the state of their applications with ease. With Redux, the state is immutable. Thus, it is possible to go back and forth to the next or previous state of your application. Redux is bound to three core principles:
- Single source of truth: All the state of your application must be stored in a single object tree within one single store
- State is read-only: You must not mutate the state tree. Only by dispatching an action can the state tree change
- Changes are made with pure functions: These are called reducers, which are functions that accept the previous state and an action and compute a new state. Reducers must never mutate the previous state but rather always return a new one
Reducers work in a very similar way to how the Array.prototype.reduce function does. The reduce...