import { minidenticon } from 'minidenticons'; import { ImgHTMLAttributes, useState } from 'react'; export function Image({ src, ...props }: ImgHTMLAttributes) { const [isError, setIsError] = useState(false); if (isError || !src) { const svgURI = 'data:image/svg+xml;utf8,' + encodeURIComponent(minidenticon(props.alt, 90, 50)); return ( {props.alt} ); } return ( { currentTarget.onerror = null; setIsError(true); }} decoding="async" alt="lume default img" style={{ contentVisibility: 'auto' }} /> ); }