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

[redux] How to handle chained selectors with the dynamic export? #274

Closed
nealoke opened this issue Jun 11, 2017 · 1 comment
Closed

[redux] How to handle chained selectors with the dynamic export? #274

nealoke opened this issue Jun 11, 2017 · 1 comment
Labels

Comments

@nealoke
Copy link

nealoke commented Jun 11, 2017

I'm wondering how you are correctly importing / exporting chained selectors. For example if you have ´client´ with multiple accounts.

(simplified example)

clients/selectors.js
export const getClient = (state) => state.client;

accounts/selectors.js (using reselect or anything else)
export const getAccounts = createSelector(getClient, (client) => client.accounts)

Using the following the dynamic export (store/selectors.js) will first export the accounts and thus the import needed for getClient in accounts gets an ùndefined.

Any idea on how to solve this?

@diegohaz
Copy link
Owner

This is probably related to #131 (comment)

You should be able to get it working by doing this:

export const getAccounts = createSelector(
  (...args) => getClient(...args), 
  (client) => client.accounts
)

I would try to avoid coupling different redux modules though.

@diegohaz diegohaz changed the title [Redux] - How to handle chained selectors with the dynamic export? [redux] How to handle chained selectors with the dynamic export? Jun 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants