diff options
author | 2022-06-27 22:27:27 +0200 | |
---|---|---|
committer | 2022-06-28 04:32:53 +0530 | |
commit | 8715d489b58534470fc0d35b5961797bc0118e84 (patch) | |
tree | 563d81196d6026945ad1898bda76e078eb2a5d82 /src/components/util | |
parent | chore: transform containers/settings from js to tsx (#384) (diff) | |
download | ferdium-app-8715d489b58534470fc0d35b5961797bc0118e84.tar.gz ferdium-app-8715d489b58534470fc0d35b5961797bc0118e84.tar.zst ferdium-app-8715d489b58534470fc0d35b5961797bc0118e84.zip |
chore: turn error boundary into typescript
Diffstat (limited to 'src/components/util')
-rw-r--r-- | src/components/util/ErrorBoundary/index.tsx (renamed from src/components/util/ErrorBoundary/index.js) | 26 | ||||
-rw-r--r-- | src/components/util/ErrorBoundary/styles.tsx (renamed from src/components/util/ErrorBoundary/styles.js) | 0 |
2 files changed, 12 insertions, 14 deletions
diff --git a/src/components/util/ErrorBoundary/index.js b/src/components/util/ErrorBoundary/index.tsx index c1861e5f7..846d6dc3f 100644 --- a/src/components/util/ErrorBoundary/index.js +++ b/src/components/util/ErrorBoundary/index.tsx | |||
@@ -1,7 +1,6 @@ | |||
1 | import { Component } from 'react'; | 1 | import { Component, ReactNode } from 'react'; |
2 | import PropTypes from 'prop-types'; | 2 | import withStyles, { WithStylesProps } from 'react-jss'; |
3 | import injectSheet from 'react-jss'; | 3 | import { defineMessages, injectIntl, IntlShape } from 'react-intl'; |
4 | import { defineMessages, injectIntl } from 'react-intl'; | ||
5 | 4 | ||
6 | import Button from '../../ui/button'; | 5 | import Button from '../../ui/button'; |
7 | import { H1 } from '../../ui/headline'; | 6 | import { H1 } from '../../ui/headline'; |
@@ -19,21 +18,20 @@ const messages = defineMessages({ | |||
19 | }, | 18 | }, |
20 | }); | 19 | }); |
21 | 20 | ||
22 | class ErrorBoundary extends Component { | 21 | interface ErrorBoundaryProps extends WithStylesProps<typeof styles> { |
22 | intl: IntlShape; | ||
23 | } | ||
24 | |||
25 | class ErrorBoundary extends Component<ErrorBoundaryProps> { | ||
23 | state = { | 26 | state = { |
24 | hasError: false, | 27 | hasError: false, |
25 | }; | 28 | }; |
26 | 29 | ||
27 | static propTypes = { | 30 | componentDidCatch(): void { |
28 | classes: PropTypes.object.isRequired, | ||
29 | children: PropTypes.node.isRequired, | ||
30 | }; | ||
31 | |||
32 | componentDidCatch() { | ||
33 | this.setState({ hasError: true }); | 31 | this.setState({ hasError: true }); |
34 | } | 32 | } |
35 | 33 | ||
36 | render() { | 34 | render(): ReactNode { |
37 | const { classes } = this.props; | 35 | const { classes } = this.props; |
38 | const { intl } = this.props; | 36 | const { intl } = this.props; |
39 | 37 | ||
@@ -56,6 +54,6 @@ class ErrorBoundary extends Component { | |||
56 | } | 54 | } |
57 | } | 55 | } |
58 | 56 | ||
59 | export default injectIntl( | 57 | export default withStyles(styles, { injectTheme: true })( |
60 | injectSheet(styles, { injectTheme: true })(ErrorBoundary), | 58 | injectIntl<'intl', ErrorBoundaryProps>(ErrorBoundary), |
61 | ); | 59 | ); |
diff --git a/src/components/util/ErrorBoundary/styles.js b/src/components/util/ErrorBoundary/styles.tsx index 0960546ff..0960546ff 100644 --- a/src/components/util/ErrorBoundary/styles.js +++ b/src/components/util/ErrorBoundary/styles.tsx | |||