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!
DISCUSSION (3)

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 Oct 10

DevOps RoadMap

I read few articles this evening and I stumbled upon a nice github repo that ha...

READ POST
Follow @joehobot to see more of their posts in your feed.
Domitrius
Front-End Engineer @ RedQueen Gaming. Javascript is cool. I code and I play things. Let's talk about it :)
Trending on dev.to
Who's looking for open source contributors? (October 15th edition)
#discuss #opensource #hacktoberfest
How to be an awesome open source maintainer?
#discuss #hacktoberfest #opensource
Barking at the right tree (1000 followers)
#meta #career #blog
How do you authenticate your users?
#security #discuss #webdev
Why "Just Unionize" Doesn't Work
#career #gamedev #computerscience
What types of features typically lead to lots of tech debt?
#discuss
dev.to Show us your octocat alter ego
#showdev #discuss
I haven't been assigned work all week. This is my first job/internship. Should I quit or stay longer?
#anonymous #discuss #career