From af8620d363c86c57a2d16ca6a1c5d812ec01d6d3 Mon Sep 17 00:00:00 2001 From: adids1221 Date: Sun, 30 Mar 2025 10:29:21 +0300 Subject: [PATCH] IconProps to support size as an object for width and height --- src/components/icon/index.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/icon/index.tsx b/src/components/icon/index.tsx index c7ae95cf6c..f012f8e32b 100644 --- a/src/components/icon/index.tsx +++ b/src/components/icon/index.tsx @@ -31,7 +31,7 @@ export type IconProps = Omit & /** * the icon size */ - size?: number; + size?: number | {width: number; height: number}; /** * whether the icon should flip horizontally on RTL */ @@ -62,7 +62,6 @@ const Icon = forwardRef((props: Props, ref: any) => { ...others } = props; const {margins} = modifiers; - const iconSize = size ? {width: size, height: size} : undefined; const shouldFlipRTL = supportRTL && Constants.isRTL; const getBadgeStyling = (): StyleProp => { @@ -77,6 +76,16 @@ const Icon = forwardRef((props: Props, ref: any) => { return [badgePosition, containerStyle]; }; + const iconSize = useMemo(() => { + if (typeof size === 'number') { + return {width: size, height: size}; + } + if (typeof size === 'object') { + return size; + } + return undefined; + }, [size]); + const iconSource = useMemo(() => { if (!isUndefined(assetName)) { return getAsset(assetName, assetGroup);