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

Multiple @connect decorators? #17

Closed
eelkeh opened this issue Jul 29, 2015 · 3 comments
Closed

Multiple @connect decorators? #17

eelkeh opened this issue Jul 29, 2015 · 3 comments

Comments

@eelkeh
Copy link

eelkeh commented Jul 29, 2015

Just asking, not sure about the best practice here.
Say a component deep in the tree needs a derived or composed state, all the "main" stores are declared on the root component... is it considered good practice to add another @connect on the deep component, or should we pass the derived state down from the root component too?

@speedskater
Copy link
Contributor

@eelkeh I think this depends on the goals you are trying to achieve.

If you add the main reducers to the top component. They will automatically trigger a rerender if your data changes. Hence you could as well pass your data down.

If some components in your hierarchy only depend on parts of the 'main' reducers I would suggest to add finer grained selectors on the root component and other connectors on the components deeper down.

e.g. in case of a form depending on your data you could select the complete form data at the root of your compound form component or you could create selectors for each form field and the selector at the root level could completely be removed.

Was this answer helpful for you?

@ellbee
Copy link
Collaborator

ellbee commented Jul 29, 2015

I agree with @speedskater, it depends!

I will add that I don't think using reselect means you should split your app into smart and dumb components any differently.

@ellbee
Copy link
Collaborator

ellbee commented Aug 20, 2015

This page from the excellent Redux documentation addresses this issue, as does this Redux issue.

@ellbee ellbee closed this as completed Aug 20, 2015
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

3 participants