Explain Redux's connect() and mapStateToProps like I'm 5

Would love to hear some different explanations around this piece of Redux! Thanks in advance :)

Did you find this post useful? Show some love!

The Store is a box, which contains the entire application state. Imagine that this box is in an unknown location.

The components need to take some of the things out of the box but they only need some of the things stored in it. The components know what they need from the box but they don't know where the box is.

The mapStateToProps function is a filter used to select which things in the box are required by the component. The selected things become the component properties.

The mapStateToProps function is not enough because it selects the required things in the box but it doesn't know where the box is located.

The connect function knows where the box is located and passes it to the mapStateToProps function so it can grab what it needs.

Great explanation. The image is a perfect pairing! Thank you.

Classic DEV Post from May 25

Stop saying you dont have time!

This week I want to talk about something that I have used for a excuse quite a few times. Before I finally started getting a schedule going. And that is saying the excuse I don’t have time to learn blank.

READ POST
Follow @alexgwartney to see more of their posts in your feed.
dev.to is now open source!
View Announcement Post View GitHub Repo
Domitrius
Front-End Dev + Rune Crafter @ RedQueen Gaming. Javascript is cool. I code and I play things. Let's talk about it :)
Trending on dev.to
How old have you been when you started programming and what was your first project?
#discuss
Explain Blockchains, Cryptocurrencies Like I'm Five
#explainlikeimfive
Explain Blockchains, Cryptocurrencies Like I'm Five
#explainlikeimfive
We Might Face The Crisis of Creative People in Next Few Years as our young generation is stuck in Just Googling Things
#discuss #crisis #humanity
How many computers do you use?
#discuss
Learning Redux and notes
#javascript #react #redux
Explain Knowledge Transfer vs Documentation like I'm five
#discuss #explainlikeimfive
Who's looking for open source contributors? (August 20 edition)
#discuss #opensource