As I collect more selectors together, I find myself reordering where the selectors are defined. For instance,
export const selectNav = state => state.nav;
export const selectPage = state => state.page;
export const selectNavAndPage = createSelector([
selectNav,
selectPage,
], (nav, page) => {
});
export const selectFoo = state => state.foo;
export const selectNavAndPageAndFoo = createSelector([
selectNavAndPage,
selectFoo,
], (navAndPage, foo) => {
});
This is a simple example, but I could not define selectNavAndPage below selectNavAndPageAndFoo. As more selectors form and selectors select form, then I need to make sure that all the selectors are defined on top before I use them.
Is there a way to create these selectors so that ordering doesn't matter?
source
share