Reputation: 1589
I saw a lot of different implementation of redux in react projects. Since today, I always follow the principle: connect a container to redux and pass down the props. In another implementation, I saw that a grand-grand-grand child can be connected to redux too. Why would you connect a child component to redux?
Upvotes: 1
Views: 197
Reputation: 31193
When you connect a child component then Redux can tell only that component to render itself when properties change. If you only connect the root component then every component has to be asked to render.
For example, if you have a component that shows the current temperature and it's a grandchild in a huge tree of components it would be much better to connect that component separately. When temperature changes only that component gets the information and others are not bothered.
In addition to this you also don't need to keep sending the props down to children. Why do the 5 parent components of the temperature component need to know about the temperature, only to push it further to the children? It doesn't concern them.
Upvotes: 2