diff options
author | 2021-07-06 21:57:57 +0200 | |
---|---|---|
committer | 2021-07-07 07:19:02 +0530 | |
commit | 63b66d5df66f454e61b7a52b4fae338c3becfc98 (patch) | |
tree | 357fa32a31db1ab45b3ed2cdc229d59a629e38a6 /src/components/ui/Tabs | |
parent | New Crowdin updates (#1612) (diff) | |
download | ferdium-app-63b66d5df66f454e61b7a52b4fae338c3becfc98.tar.gz ferdium-app-63b66d5df66f454e61b7a52b4fae338c3becfc98.tar.zst ferdium-app-63b66d5df66f454e61b7a52b4fae338c3becfc98.zip |
fix: fix breaking tab component
- move active tab state from componentDidMount to constructor
- fix toggle.tsx breaking tsc
- add .prettierrc.js for consistent formatting
Diffstat (limited to 'src/components/ui/Tabs')
-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>; |