diff --git a/packages/app/src/hooks/useTokenList.ts b/packages/app/src/hooks/useTokenList.ts index 3469070d..fb0f7ae3 100644 --- a/packages/app/src/hooks/useTokenList.ts +++ b/packages/app/src/hooks/useTokenList.ts @@ -1,22 +1,25 @@ -import { useMemo } from 'react'; import { Token } from '@uniswap/sdk-core'; import CeloTokenList from '../models/CeloTokenList.json'; import { SupportedNetwork } from '../models/constants'; +const populatedTokenList: Record = populateTokenList(); + +function populateTokenList(): Record { + const tokenList: Record = {}; + const sortedList = CeloTokenList.tokens.sort((a, b) => a.symbol.localeCompare(b.symbol)); + sortedList.forEach((token) => { + if (token.chainId !== SupportedNetwork.CELO) { + return; + } + tokenList[token.symbol] = new Token(token.chainId, token.address, token.decimals, token.symbol); + }); + return tokenList; +} + export function useToken(symbol: string): Token { - return useTokenList()[symbol]; + return populatedTokenList[symbol]; } export function useTokenList(): Record { - return useMemo(() => { - const tokenList: Record = {}; - const sortedList = CeloTokenList.tokens.sort((a, b) => a.symbol.localeCompare(b.symbol)); - sortedList.forEach((token) => { - if (token.chainId !== SupportedNetwork.CELO) { - return; - } - tokenList[token.symbol] = new Token(token.chainId, token.address, token.decimals, token.symbol); - }); - return tokenList; - }, []); + return populatedTokenList; }