Let’s break this down into three points and focus on each of them separately. Redux is for:
2. It is a State Container
It stores the state of the application as a single source of truth. This means, whenever we want to look up or share information about the state, we can always go back to that one place. In a typical react application, states can be defined in different components. Imagine, you are working on a project which has nested components, it will be really messy and as well as difficult to keep track of the state. This is where Redux can help us, by storing all the information about our state in one place.
3. It is predictable
In react application, we use the setState() method, to change the state of a component, but in redux driven applications, all state changes happen through “reducers” which are nothing but pure functions. To learn more about reducers check out getting started with the redux doc. Keep an eye out for my next blog, where I will write about the three main concepts of redux. But the take away is we can always predict the behavior of the state of our app.
React components can have their own state, then why do we need redux as a container to store all state? Let's look at the big picture:
The purpose of this blog is to introduce the bigger picture of why using redux can be useful! Understanding this concept will help to manage state in larger applications.