DEV Community

Discussion on: Explain Redux Like I'm Five

Collapse
 
vier31 profile image
Jan Schröder • Edited

Let's say, we have to tend to a vertical garden like the one below.

Vertical Garden pyramid

Now, for some silly reason, we can only water the top row. In order to get the water and the fertilizer down to the bottom row, we have to pass them through each row.

This would get pretty tedious rather quickly, no? Wouldn't it be nicer if we had a separate water tank, from which we can hydrate each flower individually, with exactly the amount of water and the exact minerals needed.

It's the same with React. Information can only be passed downwards in the component chain. So as soon as we have to pass props down for three or more layers, it becomes cumbersome. That's where Redux comes in. It provides an independent 'store' for information, that we can access from any level in the component chain.

So you can pass props from one component via the store to another component.

The function we use to access the store and get information are called Reducers.

In order to update the store, i.e. change the state of the store, we dispatch an Action.

Collapse
 
ogwurujohnson profile image
Johnson Ogwuru

Thanks alot for the explanation, I'm getting to understand it better now