import classNames from "classnames"; import { Component, InfernoNode, linkEvent } from "inferno"; interface TabItem { key: string; getNode: (isSelected: boolean) => InfernoNode; label: string; } interface TabsProps { tabs: TabItem[]; } interface TabsState { currentTab: string; } function handleSwitchTab({ ctx, tab }: { ctx: Tabs; tab: string }) { ctx.setState({ currentTab: tab }); } export default class Tabs extends Component { constructor(props: TabsProps, context) { super(props, context); this.state = { currentTab: props.tabs.length > 0 ? props.tabs[0].key : "", }; } render() { return (
{this.props.tabs.map(({ key, getNode }) => { return getNode(this.state?.currentTab === key); })}
); } }