Skip to content

Reusing extraSelectors in the createFeature #3774

Discussion options

You must be logged in to vote

Hi @alex-aghamyan-volo 👋

You can define extraSelectors factory in the following way:

export const counterFeature = createFeature({
  name: 'counter',
  reducer: createReducer({ count: 0 }),
  // 👇
  extraSelectors({ selectCount }) {
    const selectCountPlus1 = createSelector(
      selectCount,
      (count) => count + 1
    );
    const selectCountPlus2 = createSelector(
      // 👇
      selectCountPlus1,
      (count) => count + 1
    );

    return { selectCountPlus1, selectCountPlus2 };
  },
});

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@alex-aghamyan-volo
Comment options

@a-boertien
Comment options

@timdeschryver
Comment options

Answer selected by alex-aghamyan-volo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants