1 import { Component, InfernoNode, linkEvent } from "inferno";
5 getNode: () => InfernoNode;
17 function handleSwitchTab({ ctx, tab }: { ctx: Tabs; tab: string }) {
19 ctx.setState({ currentTab: tab });
22 export default class Tabs extends Component<TabsProps, TabsState> {
23 constructor(props: TabsProps, context) {
24 super(props, context);
27 currentTab: props.tabs.length > 0 ? props.tabs[0].key : "",
34 <ul className="nav nav-tabs mb-2">
35 {this.props.tabs.map(({ key, label }) => (
36 <li key={key} className="nav-item">
39 className={`nav-link btn${
40 this.state?.currentTab === key ? " active" : ""
42 onClick={linkEvent({ ctx: this, tab: key }, handleSwitchTab)}
50 .find(tab => tab.key === this.state?.currentTab)