Skip to content

Commit 7574845

Browse files
committed
feat: add onClose event
1 parent dded331 commit 7574845

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/components/tabs/index.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ export interface ITab<T = any, K = any> {
1414

1515
interface ITabsProps {
1616
data: ITab[];
17+
onClose?: (item: ITab, index: number) => void;
1718
}
1819

1920
const Tabs: React.FunctionComponent<ITabsProps> = (props: ITabsProps) => {
20-
const { data } = props;
21-
const tabs = data.map((tab: ITab) => {
22-
return (<a key={tab.id}>{tab.name}</a>);
21+
const { data, onClose } = props;
22+
const tabs = data.map((tab: ITab, index: number) => {
23+
return (<a key={tab.id}>{tab.name} <button onClick={(e) => onClose!(tab, index)}>Close</button></a>);
2324
});
2425
return (
2526
<div className={prefixClaName('tabs')}>

0 commit comments

Comments
 (0)