Commit 3f242f1b authored by Justin Domingue's avatar Justin Domingue Committed by GitHub

fix: memoize extendedEther to unnecessary rerenders (#1869)

parent 126688c7
...@@ -179,7 +179,8 @@ export function useCurrency(currencyId: string | undefined): Currency | null | u ...@@ -179,7 +179,8 @@ export function useCurrency(currencyId: string | undefined): Currency | null | u
const { chainId } = useActiveWeb3React() const { chainId } = useActiveWeb3React()
const isETH = currencyId?.toUpperCase() === 'ETH' const isETH = currencyId?.toUpperCase() === 'ETH'
const token = useToken(isETH ? undefined : currencyId) const token = useToken(isETH ? undefined : currencyId)
const extendedEther = useMemo(() => (chainId ? ExtendedEther.onChain(chainId) : undefined), [chainId])
const weth = chainId ? WETH9_EXTENDED[chainId] : undefined const weth = chainId ? WETH9_EXTENDED[chainId] : undefined
if (weth?.address?.toLowerCase() === currencyId?.toLowerCase()) return weth if (weth?.address?.toLowerCase() === currencyId?.toLowerCase()) return weth
return isETH ? (chainId ? ExtendedEther.onChain(chainId) : undefined) : token return isETH ? extendedEther : token
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment