diff --git a/src/components/Image/Image.tsx b/src/components/Image/Image.tsx index c40097ecf4..20a3664399 100644 --- a/src/components/Image/Image.tsx +++ b/src/components/Image/Image.tsx @@ -13,10 +13,7 @@ export type ImageProps = React.ImgHTMLAttributes & { } & ({ href: string; title: string } | { href?: never; title?: never }); const Image = React.forwardRef( - ( - { alt = "", className, isSrcLoading, href, title, onError, ...props }, - forwardRef - ) => { + ({ className, ...props }, forwardRef) => { const ref = useRef(null); const [isError, setError] = useState(false); @@ -26,7 +23,7 @@ const Image = React.forwardRef( () => ref.current ); - if ((!props.src && !isSrcLoading) || isError) { + if ((!props.src && !props.isSrcLoading) || isError) { return ; } @@ -48,8 +45,7 @@ const Image = React.forwardRef( * 5. Component `Image` flickers as it transitions from displaying `ContentLoader` to displaying `img` * */ - const isLoading = !ref.current?.complete && isSrcLoading; - const commonClasses = `${className} ${isLoading ? "hidden" : ""}`; + const isLoading = !ref.current?.complete && props.isSrcLoading; return ( <> @@ -66,13 +62,20 @@ const Image = React.forwardRef( * wrapping the `img`. * */} - + {alt} (onError ? onError(e) : setError(true))} - {...props} + src={props.src} + className={`object-contain ${ + isLoading ? "hidden" : "" + } ${className}`} + alt={props.alt || ""} + loading={props.loading} + onError={(e) => (props.onError ? props.onError(e) : setError(true))} />