Skip to content

Commit

Permalink
Use a createSelector to improve selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
kkosiorowska committed May 15, 2024
1 parent fcb9b62 commit 988459a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions dapp/src/store/wallet/walletSelector.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { Activity } from "#/types"
import { createSelector } from "@reduxjs/toolkit"
import { RootState } from ".."

export const selectActivities = (state: RootState): Activity[] =>
Object.values(state.wallet.activities)
export const selectActivities = createSelector(
(state: RootState) => state.wallet.activities,
(activities) => Object.values(activities),
)

export const selectActivitiesIds = (state: RootState): string[] =>
Object.keys(state.wallet.activities)
export const selectActivitiesIds = createSelector(
(state: RootState) => state.wallet.activities,
(activities) => Object.keys(activities),
)

export const selectTransactions = (state: RootState): Activity[] =>
state.wallet.transactions

0 comments on commit 988459a

Please sign in to comment.