Skip to content

Commit 08bf55e

Browse files
ref(js): Convert LoadingError to a FC (#34626)
1 parent 60d0528 commit 08bf55e

File tree

1 file changed

+25
-35
lines changed

1 file changed

+25
-35
lines changed

static/app/components/loadingError.tsx

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,41 @@
1-
import {Component} from 'react';
21
import styled from '@emotion/styled';
32

43
import Alert from 'sentry/components/alert';
54
import Button from 'sentry/components/button';
65
import {Panel} from 'sentry/components/panels';
76
import {t} from 'sentry/locale';
87

9-
type DefaultProps = {
10-
message: React.ReactNode;
11-
};
12-
13-
type Props = DefaultProps & {
8+
type Props = {
149
className?: string;
10+
message?: React.ReactNode;
1511
onRetry?: () => void;
1612
};
1713

1814
/**
19-
* Renders an Alert box of type "error". Renders a "Retry" button only if a `onRetry` callback is defined.
15+
* Renders an Alert box of type "error". Renders a "Retry" button only if a
16+
* `onRetry` callback is defined.
2017
*/
21-
class LoadingError extends Component<Props> {
22-
static defaultProps: DefaultProps = {
23-
message: t('There was an error loading data.'),
24-
};
25-
26-
shouldComponentUpdate() {
27-
return false;
28-
}
29-
30-
render() {
31-
const {message, onRetry, className} = this.props;
32-
return (
33-
<StyledAlert
34-
type="error"
35-
showIcon
36-
className={className}
37-
trailingItems={
38-
onRetry && (
39-
<Button onClick={onRetry} type="button" priority="default" size="small">
40-
{t('Retry')}
41-
</Button>
42-
)
43-
}
44-
>
45-
{message}
46-
</StyledAlert>
47-
);
48-
}
18+
function LoadingError({
19+
className,
20+
onRetry,
21+
message = t('There was an error loading data.'),
22+
}: Props) {
23+
return (
24+
<StyledAlert
25+
type="error"
26+
showIcon
27+
className={className}
28+
trailingItems={
29+
onRetry && (
30+
<Button onClick={onRetry} type="button" priority="default" size="small">
31+
{t('Retry')}
32+
</Button>
33+
)
34+
}
35+
>
36+
{message}
37+
</StyledAlert>
38+
);
4939
}
5040

5141
export default LoadingError;

0 commit comments

Comments
 (0)