As we have previously learned, there are two kinds of state in an application:
- Local state: For example, to handle input field data
- Global state: For example, to store the currently logged-in user
Previously in this book, we handled local state by using a State Hook, and more complex state (often global state) using a Reducer Hook.
Redux is a solution that can be used to handle all kinds of state in React applications. It provides a single state tree object, which contains all application state. This is similar to what we did with the Reducer Hook in our blog application. Traditionally, Redux was also often used to store local state, which makes the state tree very complex.
Redux essentially consists of five elements:
- Store: Contains state, which is an object that describes the full state of our application—{ todos: [], filter: 'all' }
- Actions...