Skip to content

Commit 5e3ecd0

Browse files
committed
chore: Avoid render icon if renderFunc return null
1 parent a15383c commit 5e3ecd0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/TransBtn.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import * as React from 'react';
22
import classNames from 'classnames';
3+
import { RenderNode } from './interface';
34

45
export interface TransBtnProps {
56
className: string;
6-
customizeIcon: React.ReactNode;
7+
customizeIcon: RenderNode;
78
customizeIconProps?: { isSelected: boolean };
89
onMouseDown?: React.MouseEventHandler<HTMLSpanElement>;
910
onClick?: React.MouseEventHandler<HTMLSpanElement>;
@@ -43,7 +44,9 @@ const TransBtn: React.FC<TransBtnProps> = ({
4344
onClick={onClick}
4445
aria-hidden
4546
>
46-
{icon || (
47+
{icon !== undefined ? (
48+
icon
49+
) : (
4750
<span className={classNames(className.split(/\s+/).map(cls => `${cls}-icon`))}>
4851
{children}
4952
</span>

0 commit comments

Comments
 (0)