@@ -4,10 +4,10 @@ import { useCurrency, useToken } from 'hooks/Tokens'
44import useTheme from 'hooks/useTheme'
55import { TimePeriod , TokenData } from 'hooks/useTopTokens'
66import { useAtom } from 'jotai'
7+ import { useAtomValue } from 'jotai/utils'
78import { darken } from 'polished'
8- import React , { ReactNode } from 'react'
9- import { ArrowDownRight , ArrowUpRight , Heart } from 'react-feather'
10- import { ArrowDown , ArrowUp } from 'react-feather'
9+ import { ReactNode , useMemo } from 'react'
10+ import { ArrowDown , ArrowDownRight , ArrowUp , ArrowUpRight , Heart } from 'react-feather'
1111import { Link } from 'react-router-dom'
1212import styled from 'styled-components/macro'
1313import { formatAmount , formatDollarAmount } from 'utils/formatDollarAmt'
@@ -19,7 +19,7 @@ import {
1919 MOBILE_MEDIA_BREAKPOINT ,
2020 SMALL_MEDIA_BREAKPOINT ,
2121} from './constants'
22- import { favoritesAtom } from './state'
22+ import { favoritesAtom , filterStringAtom } from './state'
2323import { TIME_DISPLAYS } from './TimeSelector'
2424
2525enum Category {
@@ -481,14 +481,30 @@ export default function LoadedRow({
481481 listNumber : number
482482 timePeriod : TimePeriod
483483} ) {
484+ const filterString = useAtomValue ( filterStringAtom )
484485 const token = useToken ( tokenAddress )
485- const tokenName = token ?. name
486- const tokenSymbol = token ?. symbol
486+ const currency = useCurrency ( tokenAddress )
487+ const tokenName = token ?. name ?? ''
488+ const tokenSymbol = token ?. symbol ?? ''
487489 const tokenData = data [ tokenAddress ]
488490 const [ favoriteTokens , updateFavoriteTokens ] = useAtom ( favoritesAtom )
489491 const theme = useTheme ( )
490492 const isFavorited = favoriteTokens . includes ( tokenAddress )
491493
494+ const showRow = useMemo ( ( ) => {
495+ if ( ! filterString ) {
496+ return true
497+ }
498+ const lowercaseFilterString = filterString . toLowerCase ( )
499+ const addressIncludesFilterString = tokenAddress . toLowerCase ( ) . includes ( lowercaseFilterString )
500+ const nameIncludesFilterString = tokenName . toLowerCase ( ) . includes ( lowercaseFilterString )
501+ const symbolIncludesFilterString = tokenSymbol . toLowerCase ( ) . includes ( lowercaseFilterString )
502+ return nameIncludesFilterString || symbolIncludesFilterString || addressIncludesFilterString
503+ } , [ filterString , tokenAddress , tokenName , tokenSymbol ] )
504+
505+ if ( ! showRow ) {
506+ return null
507+ }
492508 const tokenPercentChangeInfo = (
493509 < >
494510 { tokenData . delta } %
@@ -530,7 +546,7 @@ export default function LoadedRow({
530546 listNumber = { listNumber }
531547 tokenInfo = {
532548 < ClickableName to = { `tokens/${ tokenAddress } ` } >
533- < CurrencyLogo currency = { useCurrency ( tokenAddress ) } />
549+ < CurrencyLogo currency = { currency } />
534550 < TokenInfoCell >
535551 < TokenName > { tokenName } </ TokenName >
536552 < TokenSymbol > { tokenSymbol } </ TokenSymbol >
0 commit comments