diff --git a/packages/design-system/image/image.web.tsx b/packages/design-system/image/image.web.tsx index be2f29a774..0cd90cca43 100644 --- a/packages/design-system/image/image.web.tsx +++ b/packages/design-system/image/image.web.tsx @@ -1,4 +1,4 @@ -import { ComponentProps, CSSProperties, useCallback } from "react"; +import { ComponentProps, CSSProperties, useCallback, useMemo } from "react"; import { ImageURISource } from "react-native"; // @ts-ignore @@ -73,18 +73,37 @@ function Img({ }, [onLoad, onLoadingCompleteProps] ); + + const newProps = useMemo(() => { + return { + style: { + objectFit: (contentFit ?? resizeMode) as any, + ...style, + }, + alt: alt ?? "", + width, + height, + fill: !hasHeightOrWidth, + loading, + priority: loading === "eager", + ...props, + }; + }, [ + alt, + contentFit, + hasHeightOrWidth, + height, + loading, + props, + resizeMode, + style, + width, + ]); + if (source?.uri && typeof source?.uri === "string") { return ( 40 && props.blurhash ? "blur" : "empty"} blurDataURL={ @@ -92,27 +111,14 @@ function Img({ ? getBase64Blurhash(props.blurhash) : undefined } - alt={alt ?? ""} - fill={!hasHeightOrWidth} unoptimized // We already optimize the images with our CDN - {...props} + {...newProps} /> ); } if (typeof source === "string") { - return ( - {alt - ); + return ; } return null; @@ -124,11 +130,12 @@ function StyledImage({ borderRadius = 0, tw = "", ...props }: ImageProps) { return (