Skip to content

Commit 52300f6

Browse files
ref(js): Convert gridEditable/sortLink to a FC (#34615)
1 parent 08bf55e commit 52300f6

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

static/app/components/gridEditable/sortLink.tsx

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {Component} from 'react';
21
import styled from '@emotion/styled';
32
import {LocationDescriptorObject} from 'history';
43
import omit from 'lodash/omit';
@@ -19,34 +18,22 @@ type Props = {
1918
onClick?: (e: React.MouseEvent<HTMLAnchorElement>) => void;
2019
};
2120

22-
class SortLink extends Component<Props> {
23-
renderArrow() {
24-
const {direction} = this.props;
25-
if (!direction) {
26-
return null;
27-
}
21+
function SortLink({align, title, canSort, generateSortLink, onClick, direction}: Props) {
22+
const target = generateSortLink();
2823

29-
if (direction === 'desc') {
30-
return <StyledIconArrow size="xs" direction="down" />;
31-
}
32-
return <StyledIconArrow size="xs" direction="up" />;
24+
if (!target || !canSort) {
25+
return <StyledNonLink align={align}>{title}</StyledNonLink>;
3326
}
3427

35-
render() {
36-
const {align, title, canSort, generateSortLink, onClick} = this.props;
28+
const arrow = !direction ? null : (
29+
<StyledIconArrow size="xs" direction={direction === 'desc' ? 'down' : 'up'} />
30+
);
3731

38-
const target = generateSortLink();
39-
40-
if (!target || !canSort) {
41-
return <StyledNonLink align={align}>{title}</StyledNonLink>;
42-
}
43-
44-
return (
45-
<StyledLink align={align} to={target} onClick={onClick}>
46-
{title} {this.renderArrow()}
47-
</StyledLink>
48-
);
49-
}
32+
return (
33+
<StyledLink align={align} to={target} onClick={onClick}>
34+
{title} {arrow}
35+
</StyledLink>
36+
);
5037
}
5138

5239
type LinkProps = React.ComponentPropsWithoutRef<typeof Link>;

0 commit comments

Comments
 (0)