Explain Redux to me like I am a five year old, what it is and why it is important?
For further actions, you may consider blocking this person and/or reporting abuse
Explain Redux to me like I am a five year old, what it is and why it is important?
For further actions, you may consider blocking this person and/or reporting abuse
Adeleye Ayodeji -
Jess Lee -
Joan Roucoux -
keploy -
Top comments (3)
You know that Nintendo Switch case you have that stores all your games? Well, Redux is like that for storing little pieces of state that you want to access from anywhere in your application. Just as if you wanted to play a Switch game, you wouldn’t want to search all over the house for where the original game packaging is, you would want to go to a single place to find it, your Switch case.
React is Component based library and thus you need a away to allow communication between these Components. Sure you can pass props from Component to Component, but once number of your Components grows, it will hard to to get whole picture of properties that are used in your React application, let alone modify them.
Enter Redux. At the heart of it is a store that combines all of your properties in one place. It's like a real store - you don't have to run around all manufacturers (Components) to get an item you want (Property), you just go to the store and choose which item (Property) you want to get. You don't drive to DeWalt to buy their drill, you drive to Home Depot to buy it, and while there pick up other things as well.
From a React POV:
Store: A single place to store information (Like a book someone else is writing for you)
Action: Little piece of message you send (dispatch) to the store (Requests to the writer)
Reducer: Logic to interpret the message and edit the store (How the writer should act according to the requests)
Middleware: They have access to what's going on (Like someone who is listening to all the requests you sent to the writer)
I hope that's basic enough...