saleor-dashboard/src/components/Tab/Tabs.tsx

32 lines
570 B
TypeScript
Raw Normal View History

2019-06-19 14:40:52 +00:00
import * as React from "react";
export interface TabsProps {
children: (
props: {
changeTab: (index: number) => void;
currentTab: number;
}
) => React.ReactNode;
}
interface TabsState {
currentTab: number;
}
class Tabs extends React.Component<TabsProps, TabsState> {
state: TabsState = {
currentTab: 0
};
changeTab = (index: number) => this.setState({ currentTab: index });
render() {
return this.props.children({
changeTab: this.changeTab,
currentTab: this.state.currentTab
});
}
}
export default Tabs;