diff options
author | 2021-10-14 13:24:58 +0200 | |
---|---|---|
committer | 2021-10-14 13:24:58 +0200 | |
commit | fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e (patch) | |
tree | 10caa332d957421e982c7ddd0c94623d5d62314d /src/components/ui/AppLoader | |
parent | chore: convert various JS to TS (#2062) (diff) | |
download | ferdium-app-fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e.tar.gz ferdium-app-fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e.tar.zst ferdium-app-fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e.zip |
chore: convert files to TS (#2066)
Diffstat (limited to 'src/components/ui/AppLoader')
-rw-r--r-- | src/components/ui/AppLoader/index.tsx (renamed from src/components/ui/AppLoader/index.js) | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/components/ui/AppLoader/index.js b/src/components/ui/AppLoader/index.tsx index e00960200..c7c290a57 100644 --- a/src/components/ui/AppLoader/index.js +++ b/src/components/ui/AppLoader/index.tsx | |||
@@ -1,5 +1,4 @@ | |||
1 | import { Component } from 'react'; | 1 | import { Component } from 'react'; |
2 | import PropTypes from 'prop-types'; | ||
3 | import injectSheet, { withTheme } from 'react-jss'; | 2 | import injectSheet, { withTheme } from 'react-jss'; |
4 | import classnames from 'classnames'; | 3 | import classnames from 'classnames'; |
5 | 4 | ||
@@ -19,15 +18,15 @@ const textList = shuffleArray([ | |||
19 | 'Fixing bugs', | 18 | 'Fixing bugs', |
20 | ]); | 19 | ]); |
21 | 20 | ||
21 | type Props = { | ||
22 | classes: typeof styles; | ||
23 | theme: any; | ||
24 | texts: string[]; | ||
25 | }; | ||
26 | |||
22 | @injectSheet(styles) | 27 | @injectSheet(styles) |
23 | @withTheme | 28 | @withTheme |
24 | class AppLoader extends Component { | 29 | class AppLoader extends Component<Props> { |
25 | static propTypes = { | ||
26 | classes: PropTypes.object.isRequired, | ||
27 | theme: PropTypes.object.isRequired, | ||
28 | texts: PropTypes.array, | ||
29 | }; | ||
30 | |||
31 | static defaultProps = { | 30 | static defaultProps = { |
32 | texts: textList, | 31 | texts: textList, |
33 | }; | 32 | }; |
@@ -36,18 +35,20 @@ class AppLoader extends Component { | |||
36 | step: 0, | 35 | step: 0, |
37 | }; | 36 | }; |
38 | 37 | ||
39 | interval = null; | 38 | interval: NodeJS.Timeout | null = null; |
40 | 39 | ||
41 | componentDidMount() { | 40 | componentDidMount() { |
42 | this.interval = setInterval(() => { | 41 | this.interval = setInterval(() => { |
43 | this.setState(prevState => ({ | 42 | this.setState((prevState: { step: number }) => ({ |
44 | step: prevState.step === textList.length - 1 ? 0 : prevState.step + 1, | 43 | step: prevState.step === textList.length - 1 ? 0 : prevState.step + 1, |
45 | })); | 44 | })); |
46 | }, 2500); | 45 | }, 2500); |
47 | } | 46 | } |
48 | 47 | ||
49 | componentWillUnmount() { | 48 | componentWillUnmount() { |
50 | clearInterval(this.interval); | 49 | if (this.interval) { |
50 | clearInterval(this.interval); | ||
51 | } | ||
51 | } | 52 | } |
52 | 53 | ||
53 | render() { | 54 | render() { |