Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this a good idea to connect nested components? #159

Closed
tadjik1 opened this issue Oct 15, 2015 · 7 comments
Closed

Is this a good idea to connect nested components? #159

tadjik1 opened this issue Oct 15, 2015 · 7 comments

Comments

@tadjik1
Copy link

tadjik1 commented Oct 15, 2015

On each page on my website I have many components and I don't want to control fetching and grabing data from store for every component just in one "smart" top-level component. So I want to connect nested components too. Is this a good pattern? Will I meet a perfomance troubles with this way of connect? What I need to know about connected components behavior for avoiding troubles?

@gaearon
Copy link
Contributor

gaearon commented Oct 15, 2015

Please see reduxjs/redux#419.

Both approaches are fine, and having nested connect() components is actually going to give you more performance. The downside is they're slightly more coupled to the application and slightly harder to test, but that may not be a big issue.

@gaearon gaearon closed this as completed Oct 15, 2015
@tadjik1
Copy link
Author

tadjik1 commented Oct 15, 2015

thanks!

@esamattis
Copy link
Contributor

I recommend usage of redux-batched-updates as it can avoid some serious headaches. See 3.0.0 release notes. It will also improve performance in some cases.

@natevw
Copy link

natevw commented Jan 18, 2017

I started wondering the same thing, whether connect was intended to be used on ± every component individually, or only on the top level component. The link @gaearon gives is broken, I think reduxjs/redux#419 is the correct thread to refer to for more discussion.

@markerikson
Copy link
Contributor

markerikson commented Jan 18, 2017

The current answer to this question is in the Redux FAQ. See http://redux.js.org/docs/faq/ReactRedux.html#react-multiple-components . My recent blog post at http://blog.isquaredsoftware.com/2017/01/practical-redux-part-6-connected-lists-forms-and-performance/ also discusses the idea of multiple connected components and performance.

@alexmcmillan
Copy link

@gaearon update for rotten link: reduxjs/redux#419

@PabloDinella
Copy link

The current answer to this question is in the Redux FAQ. See http://redux.js.org/docs/faq/ReactRedux.html#react-multiple-components . My recent blog post at http://blog.isquaredsoftware.com/2017/01/practical-redux-part-6-connected-lists-forms-and-performance/ also discusses the idea of multiple connected components and performance.

Updated link: https://redux.js.org/faq/react-redux#should-i-only-connect-my-top-component-or-can-i-connect-multiple-components-in-my-tree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants