2021-07-01 18:21:40 +00:00
|
|
|
import React, { Suspense } from "react";
|
|
|
|
import { useImage } from "react-image";
|
|
|
|
|
|
|
|
type TokenLogoProps = {
|
|
|
|
address: string;
|
|
|
|
name: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
const TokenLogo: React.FC<TokenLogoProps> = (props) => (
|
|
|
|
<Suspense fallback={<></>}>
|
|
|
|
<InternalTokenLogo {...props} />
|
|
|
|
</Suspense>
|
|
|
|
);
|
|
|
|
|
|
|
|
const InternalTokenLogo: React.FC<TokenLogoProps> = ({ address, name }) => {
|
|
|
|
const { src } = useImage({
|
|
|
|
srcList: [
|
2021-07-07 19:59:49 +00:00
|
|
|
`http://localhost:3001/assets/${address}/logo.png`,
|
2021-07-01 18:21:40 +00:00
|
|
|
"/eth-diamond-black.png",
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="flex items-center justify-center w-5 h-5">
|
|
|
|
<img className="max-w-full max-h-full" src={src} alt={`${name} logo`} />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default React.memo(TokenLogo);
|