1- import { Component } from 'react' ;
21import styled from '@emotion/styled' ;
32import { LocationDescriptorObject } from 'history' ;
43import 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
5239type LinkProps = React . ComponentPropsWithoutRef < typeof Link > ;
0 commit comments