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 = {
|
2022-06-21 09:36:55 +00:00
|
|
|
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,
|
2022-06-21 09:36:55 +00:00
|
|
|
currentTab: this.state.currentTab,
|
2019-06-19 14:40:52 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Tabs;
|