DEV Community

Cover image for Explain Redux to me like I am five.
Nedy Udombat
Nedy Udombat

Posted on

Explain Redux to me like I am five.

Explain Redux to me like I am a five year old, what it is and why it is important?

Top comments (3)

Collapse
 
crock profile image
Alex Crocker

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.

Collapse
 
akravets profile image
akravets

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.

Collapse
 
skydevht profile image
Holy-Elie Scaïde • Edited

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...