import React, { useContext } from "react"; import { useImage } from "react-image"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faCoins } from "@fortawesome/free-solid-svg-icons/faCoins"; import { tokenLogoURL } from "../url"; import { RuntimeContext } from "../useRuntime"; import { ChecksummedAddress } from "../types"; type TokenLogoProps = { address: ChecksummedAddress; name: string; }; const TokenLogo: React.FC = ({ address, name }) => { const { config } = useContext(RuntimeContext); const srcList: string[] = []; if (config) { srcList.push(tokenLogoURL(config.assetsURLPrefix ?? "", address)); } const { src, isLoading } = useImage({ srcList, useSuspense: false }); return (
{src && ( {`${name} )} {!src && !isLoading && }
); }; export default React.memo(TokenLogo);