You use the react-redux utility with the mapStateToProps function, which does the thing as it's called, so that whenever the state (of the store) changes, the props changes as well. And it triggers the re-render of react components.
Internally React Redux works by calling store.subscribe() when the component mounts. Every time the Redux store changes, the subscription callback fires. Inside it, React Redux calls React setState() by taking Redux store state and passing it through mapStateToProps().
Thanks Dan, the code example is really helpful. Also I found your video talk about react-redux very inspiring and straight-forward as well. For those who are interested, you can go to youtube.com/watch?v=VJ38wSFbM3A. <3
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You use the
react-redux
utility with the mapStateToProps function, which does the thing as it's called, so that whenever the state (of the store) changes, the props changes as well. And it triggers the re-render of react components.Thanks, Chang! I think I wasn't clear enough, I'm sorry! I meant the details of the implementation of such patterns.
Internally React Redux works by calling
store.subscribe()
when the component mounts. Every time the Redux store changes, the subscription callback fires. Inside it, React Redux calls ReactsetState()
by taking Redux store state and passing it throughmapStateToProps()
.Here’s a simple version: gist.github.com/gaearon/1d19088790...
Thank you so much! That's exactly what I wanted to know :D
Thanks Dan, the code example is really helpful. Also I found your video talk about react-redux very inspiring and straight-forward as well. For those who are interested, you can go to
youtube.com/watch?v=VJ38wSFbM3A. <3