diff options
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/ui/Tabs/Tabs.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/components/ui/Tabs/Tabs.js b/src/components/ui/Tabs/Tabs.js index 7ece29fbe..e68dc3a1d 100644 --- a/src/components/ui/Tabs/Tabs.js +++ b/src/components/ui/Tabs/Tabs.js | |||
@@ -8,6 +8,11 @@ import { oneOrManyChildElements } from '../../../prop-types'; | |||
8 | export default | 8 | export default |
9 | @observer | 9 | @observer |
10 | class Tab extends Component { | 10 | class Tab extends Component { |
11 | constructor(props) { | ||
12 | super(props); | ||
13 | this.state = { active: this.props.active }; | ||
14 | } | ||
15 | |||
11 | static propTypes = { | 16 | static propTypes = { |
12 | children: oneOrManyChildElements.isRequired, | 17 | children: oneOrManyChildElements.isRequired, |
13 | active: PropTypes.number, | 18 | active: PropTypes.number, |
@@ -17,17 +22,13 @@ class Tab extends Component { | |||
17 | active: 0, | 22 | active: 0, |
18 | }; | 23 | }; |
19 | 24 | ||
20 | componentDidMount() { | ||
21 | this.setState({ active: this.props.active }); | ||
22 | } | ||
23 | |||
24 | switchTab(index) { | 25 | switchTab(index) { |
25 | this.setState({ active: index }); | 26 | this.setState({ active: index }); |
26 | } | 27 | } |
27 | 28 | ||
28 | render() { | 29 | render() { |
29 | const { children: childElements } = this.props; | 30 | const { children: childElements } = this.props; |
30 | const children = childElements.filter((c) => !!c); | 31 | const children = childElements.filter(c => !!c); |
31 | 32 | ||
32 | if (children.length === 1) { | 33 | if (children.length === 1) { |
33 | return <div>{children}</div>; | 34 | return <div>{children}</div>; |