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

30 lines
553 B
TypeScript
Raw Normal View History

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