-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTab.tsx
34 lines (31 loc) · 822 Bytes
/
Tab.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import headlessEngine from "../../Engine";
import { buildTab, TabProps, Tab as HeadlessTab } from "@coveo/headless";
import React from "react";
import "./Tab.css";
export default class Tab extends React.Component<TabProps> {
private headlessTab: HeadlessTab;
constructor(props: any) {
super(props);
this.headlessTab = buildTab(headlessEngine, props);
this.state = this.headlessTab.state;
}
componentDidMount() {
this.headlessTab.subscribe(() => this.updateState());
}
updateState() {
this.setState(this.headlessTab.state);
}
render() {
return (
<button
className="tabBar"
disabled={this.headlessTab.state.isActive}
onClick={() => {
this.headlessTab.select();
}}
>
{this.props.options.id}
</button>
);
}
}