Skip to content

Commit 875ad92

Browse files
committed
fix(Tag): closeable not work
1 parent 990d763 commit 875ad92

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/components/tag/Tag.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const TagFunction: ForwardRefRenderFunction<HTMLDivElement, TagProps> = (
7171
className,
7272
);
7373

74-
const TagCloseIcon = () => {
74+
const tagCloseIcon = useMemo(() => {
7575
const iconNode = tagConfig?.closeIcon ? tagConfig.closeIcon : <CloseIcon />;
7676
if (React.isValidElement(iconNode)) {
7777
const element = iconNode as React.ReactElement<any>;
@@ -84,7 +84,8 @@ export const TagFunction: ForwardRefRenderFunction<HTMLDivElement, TagProps> = (
8484
className: classNames(element.props?.className, `${tagClassPrefix}__icon-close`),
8585
});
8686
}
87-
};
87+
return null;
88+
}, [CloseIcon, disabled, tagClassPrefix, tagConfig.closeIcon, onClose]);
8889

8990
const title = useMemo(() => {
9091
if (Reflect.has(props, 'title')) return titleAttr;
@@ -143,7 +144,7 @@ export const TagFunction: ForwardRefRenderFunction<HTMLDivElement, TagProps> = (
143144
<span className={maxWidth ? `${tagClassPrefix}--text` : undefined} style={getTextStyle} {...titleAttribute}>
144145
{children ?? content}
145146
</span>
146-
{closable && !disabled && <TagCloseIcon />}
147+
{closable && !disabled && tagCloseIcon}
147148
</>
148149
</div>
149150
);

0 commit comments

Comments
 (0)