aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/util/ErrorBoundary
diff options
context:
space:
mode:
authorLibravatar Ricardo Cino <ricardo@cino.io>2022-06-27 22:27:27 +0200
committerLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2022-06-28 04:32:53 +0530
commit8715d489b58534470fc0d35b5961797bc0118e84 (patch)
tree563d81196d6026945ad1898bda76e078eb2a5d82 /src/components/util/ErrorBoundary
parentchore: transform containers/settings from js to tsx (#384) (diff)
downloadferdium-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/ErrorBoundary')
-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 @@
1import { Component } from 'react'; 1import { Component, ReactNode } from 'react';
2import PropTypes from 'prop-types'; 2import withStyles, { WithStylesProps } from 'react-jss';
3import injectSheet from 'react-jss'; 3import { defineMessages, injectIntl, IntlShape } from 'react-intl';
4import { defineMessages, injectIntl } from 'react-intl';
5 4
6import Button from '../../ui/button'; 5import Button from '../../ui/button';
7import { H1 } from '../../ui/headline'; 6import { H1 } from '../../ui/headline';
@@ -19,21 +18,20 @@ const messages = defineMessages({
19 }, 18 },
20}); 19});
21 20
22class ErrorBoundary extends Component { 21interface ErrorBoundaryProps extends WithStylesProps<typeof styles> {
22 intl: IntlShape;
23}
24
25class 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
59export default injectIntl( 57export 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