The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Redux: Passing the Store Down Explicitly via Props

Redux: Passing the Store Down Explicitly via Props

3:54
Learn how to pass store down as a prop to container components instead of declaring a top-level variable to prepare for easier testing and server rendered applications.
Watch this lesson now
Avatar
egghead.io

Learn how to pass store down as a prop to container components instead of declaring a top-level variable to prepare for easier testing and server rendered applications.

Avatar
Arthur

Is it a concern that some components are subscribing to the whole store without using all of the elements in the store? For instance, the Footer is going to ForceUpdate every time a new todo item is added correct? Is this OK because React won't actually trigger an update of the child component because it's props didn't change? Can this cause performance issues if lots of items are being displayed like you mention in your SO answer here?

Avatar
Dan Abramov

Yes, this would be a performance concern. You can hand write optimizations in the container components, or you can use connect() from next lessons that does that for you.

In reply to Arthur
Avatar
Arthur

Thanks for replying. So connect automatically determines which part of the state tree to pass down? Or more specifically, the part of the state that gets applied to the props in connect is the only part that is subscribed to?

In reply to Dan Abramov
Avatar
Dan Abramov

The components generated by connect() behave very similarly to those I wrote by hand, but they use setState() instead of forceUpdate() and implement a performant shouldComponentUpdate() optimization which skips rendering if the part of the state selected by mapStateToProps() has not changed.

In reply to Arthur
Avatar
Arthur

Thanks! Thanks for the great tutorial.

In reply to Dan Abramov
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?