Skip to content

Commit 21d9403

Browse files
committed
fix(Icon): prop passing
1 parent 91a6cf9 commit 21d9403

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

.size-limit.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = [
2020
}),
2121
);
2222
},
23-
limit: '246kB',
23+
limit: '247kB',
2424
},
2525
{
2626
name: 'Tree shaking (just a Button)',

src/icons/Icon.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export interface CubeIconProps
4848
BaseStyleProps {
4949
size?: Styles['fontSize'];
5050
stroke?: number;
51-
children: ReactElement;
51+
children?: ReactElement;
5252
}
5353

5454
export const Icon = memo(
@@ -58,10 +58,12 @@ export const Icon = memo(
5858
) {
5959
const { size, stroke, ...rest } = props;
6060

61-
const icon = cloneElement(rest.children, {
62-
size: typeof size === 'number' ? size : undefined,
63-
stroke,
64-
});
61+
const icon = rest.children
62+
? cloneElement(rest.children, {
63+
size: typeof size === 'number' ? size : undefined,
64+
stroke,
65+
})
66+
: rest.children;
6567

6668
return (
6769
<IconElement

src/icons/wrap-icon.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { ReactNode } from 'react';
1+
import { ReactElement } from 'react';
22

33
import { CubeIconProps, Icon } from './Icon';
44

5-
export function wrapIcon(name: string, icon: ReactNode) {
5+
export function wrapIcon(name: string, icon: ReactElement) {
66
function IconWrapper(props: CubeIconProps) {
77
return (
88
// use custom size to support legacy icons

0 commit comments

Comments
 (0)