Skip to content

Commit 09a3b23

Browse files
authored
IconProps to support size as an object for width and height (#3660)
1 parent 6b4eebc commit 09a3b23

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/components/icon/index.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type IconProps = Omit<RNImageProps, 'source' | 'tintColor'> &
3131
/**
3232
* the icon size
3333
*/
34-
size?: number;
34+
size?: number | {width: number; height: number};
3535
/**
3636
* whether the icon should flip horizontally on RTL
3737
*/
@@ -62,7 +62,6 @@ const Icon = forwardRef((props: Props, ref: any) => {
6262
...others
6363
} = props;
6464
const {margins} = modifiers;
65-
const iconSize = size ? {width: size, height: size} : undefined;
6665
const shouldFlipRTL = supportRTL && Constants.isRTL;
6766

6867
const getBadgeStyling = (): StyleProp<ViewStyle> => {
@@ -77,6 +76,16 @@ const Icon = forwardRef((props: Props, ref: any) => {
7776
return [badgePosition, containerStyle];
7877
};
7978

79+
const iconSize = useMemo(() => {
80+
if (typeof size === 'number') {
81+
return {width: size, height: size};
82+
}
83+
if (typeof size === 'object') {
84+
return size;
85+
}
86+
return undefined;
87+
}, [size]);
88+
8089
const iconSource = useMemo(() => {
8190
if (!isUndefined(assetName)) {
8291
return getAsset(assetName, assetGroup);

0 commit comments

Comments
 (0)