What is Redux in simple terms with React?
I found it very difficult when I started with redux I went through a lot of tutorials, unlimited Youtube video tutorials and a lot of blogs as well. But after working in redux on my projects I found it to be less daunting and got to know the importance how it helps us(Powerful tool).
So the difficulty curve for Redux is very high in the beginning you will not understand anything easily but as you start working on that the difficulty curve will decrease and you will enjoy it more.
So in this post I will explain what exactly is redux in layman’s term.
So if you go to the docs of redux it will say A Predictable State Container for JS Apps but a beginner can not understand this statement.
I will explain this with an example:
Suppose If you go to a grocery store(the grocery store has vegetables, fruits, juices and eggs) and you are a customer and you went to the shop and ask for vegetables then the shop owner will go to the vegetable section and gets you the desired vegetable(same applies for vegetable, fruits etc..). So the shopkeeper has kept separate sections for all the 4 items to make it handy.
What if the owner has mixed all the items in the store and a customer comes and orders a particular item then he will get confused and it will become very complex for him to find the particular item.
So if anything is sorted out individually then it will be easy to pick an item right. If it makes sense. So this is what Redux is all about. It just keeps apart everything and makes your application less complex.
So it has 3 main parts 1)Actions 2)Reducer 3)Store
So what is Action Now we will jump back to the example mentioned above so if a customer ask for a particular grocery item then that will become our Action for us(ex.. eggs, vegetable etc..). Now the owner receives the Action and the owner will go to the Store and everything is sorted based on vegetables, eggs etc.. Now the owner will go to the particular action(what customer has ordered) and go to that section and picks the grocery and give it back to customer this is what a reducer does. based on a particular action he searches in a store and gets the item. And store is a warehouse where all the data/grocery items is present.
This is what Redux in a nutshell(in simple terms)
Till then Happy Coding and please comment if you find it useful or to improve anything.