Skip to content

Commit

Permalink
feat: add onClose event
Browse files Browse the repository at this point in the history
  • Loading branch information
wewoor committed Nov 3, 2020
1 parent dded331 commit 7574845
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ export interface ITab<T = any, K = any> {

interface ITabsProps {
data: ITab[];
onClose?: (item: ITab, index: number) => void;
}

const Tabs: React.FunctionComponent<ITabsProps> = (props: ITabsProps) => {
const { data } = props;
const tabs = data.map((tab: ITab) => {
return (<a key={tab.id}>{tab.name}</a>);
const { data, onClose } = props;
const tabs = data.map((tab: ITab, index: number) => {
return (<a key={tab.id}>{tab.name} <button onClick={(e) => onClose!(tab, index)}>Close</button></a>);
});
return (
<div className={prefixClaName('tabs')}>
Expand Down

0 comments on commit 7574845

Please sign in to comment.