Skip to content

Commit 955ee0e

Browse files
committed
fix(Tab): Fixed issue where icons as elements not rendering
1 parent cd23e91 commit 955ee0e

File tree

1 file changed

+14
-33
lines changed

1 file changed

+14
-33
lines changed

src/components/Tab/Tab.tsx

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,21 @@ function getTabUI(props: any) {
1010
export const Tab = (props: any) => {
1111
const { icon, ...rest } = props;
1212
const Wrapper: any = getTabUI;
13-
const Styled = withStyles(props.styles)(Wrapper);
13+
const Styled = withStyles(props.styles || {})(Wrapper);
1414

15-
// const CustomIcon: React.ElementType = () => {
16-
// if (!icon) {
17-
// return null;
18-
// }
19-
// const size = icon.size || 24;
15+
let iconNode;
2016

21-
// const iconProps = {
22-
// size,
23-
// style: {
24-
// lineHeight: size,
25-
// ...icon.style,
26-
// },
27-
// ...icon,
28-
// };
17+
if (React.isValidElement(icon)) {
18+
iconNode = icon;
19+
} else if (!!icon) {
20+
iconNode = (
21+
<DynamicIcon
22+
size={icon.size || 24}
23+
style={{ lineHeight: icon.size || 24, ...icon.style }}
24+
{...icon}
25+
/>
26+
);
27+
}
2928

30-
// return <DynamicIcon {...iconProps} />;
31-
// };
32-
return (
33-
<Styled
34-
{...rest}
35-
icon={
36-
// <CustomIcon />
37-
icon ? (
38-
<DynamicIcon
39-
size={icon.size || 24}
40-
style={{ lineHeight: icon.size || 24, ...icon.style }}
41-
{...icon}
42-
/>
43-
) : (
44-
undefined
45-
)
46-
}
47-
/>
48-
);
29+
return <Styled {...rest} icon={iconNode} />;
4930
};

0 commit comments

Comments
 (0)