Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepinho committed Jan 6, 2025
1 parent f2e2e74 commit b53d703
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -18,5 +25,5 @@ export default function useFilteredAssets() {
[searchText],
);

return filteredTokens;
return filteredAssets;
}

0 comments on commit b53d703

Please sign in to comment.