From 6f47cd12f00c09a1ee8beec615d21d50547597a0 Mon Sep 17 00:00:00 2001 From: Jesse Pinho Date: Fri, 3 Jan 2025 15:31:17 -0800 Subject: [PATCH] Comments --- .../DefaultPaymentTokenScreen/useFilteredAssets.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/react-native-expo/components/ProfileScreen/DefaultPaymentTokenScreen/useFilteredAssets.ts b/react-native-expo/components/ProfileScreen/DefaultPaymentTokenScreen/useFilteredAssets.ts index 1ce0ca7..34c8ee9 100644 --- a/react-native-expo/components/ProfileScreen/DefaultPaymentTokenScreen/useFilteredAssets.ts +++ b/react-native-expo/components/ProfileScreen/DefaultPaymentTokenScreen/useFilteredAssets.ts @@ -2,10 +2,17 @@ import { useAppSelector } from '@/store/hooks'; import ASSETS from './assets'; import { useMemo } from 'react'; +/** + * Returns asset types filtered by the search text from state. + * + * The filtered results are memoized for performance reasons. In the future, if + * typing search text becomes slow, consider adding throttling updates to + * `filteredAssets`. + */ export default function useFilteredAssets() { const searchText = useAppSelector(state => state.defaultPaymentTokenScreen.searchText); - const filteredTokens = useMemo( + const filteredAssets = useMemo( () => ASSETS.filter(asset => { const searchTextLowerCase = searchText.toLocaleLowerCase(); @@ -18,5 +25,5 @@ export default function useFilteredAssets() { [searchText], ); - return filteredTokens; + return filteredAssets; }