@@ -10,26 +10,31 @@ type SelectAllProps = {
10
10
toggleSelectAll ( ) : void ;
11
11
visible : boolean ;
12
12
} ;
13
- const SelectAll : React . FC < SelectAllProps > = React . memo (
14
- ( {
15
- tabIndex,
16
- disabled,
17
- allSelected,
18
- id,
19
- selectAllText,
20
- toggleSelectAll,
21
- visible,
22
- } ) => {
23
- const checkboxRef = React . useRef < HTMLInputElement > ( ) ;
24
13
25
- React . useEffect ( ( ) => {
26
- if ( checkboxRef . current ) {
27
- checkboxRef . current . indeterminate = allSelected === 'partial' ;
14
+ class SelectAll extends React . PureComponent < SelectAllProps > {
15
+ static displayName = 'Picky(SelectAll)' ;
16
+ checkboxRef = React . createRef < HTMLInputElement > ( ) ;
17
+
18
+ componentDidUpdate ( prevProps : SelectAllProps ) {
19
+ if ( prevProps . allSelected !== this . props . allSelected ) {
20
+ if ( this . checkboxRef && this . checkboxRef . current ) {
21
+ this . checkboxRef . current . indeterminate =
22
+ this . props . allSelected === 'partial' ;
28
23
}
29
- } , [ allSelected ] ) ;
30
- if ( ! visible ) {
31
- return null ;
32
24
}
25
+ }
26
+ render ( ) {
27
+ const {
28
+ tabIndex,
29
+ disabled,
30
+ allSelected,
31
+ id,
32
+ selectAllText,
33
+ toggleSelectAll,
34
+ visible,
35
+ } = this . props ;
36
+
37
+ if ( ! visible ) return null ;
33
38
return (
34
39
< div
35
40
tabIndex = { tabIndex }
@@ -44,7 +49,7 @@ const SelectAll: React.FC<SelectAllProps> = React.memo(
44
49
>
45
50
< input
46
51
type = "checkbox"
47
- ref = { checkboxRef }
52
+ ref = { this . checkboxRef }
48
53
readOnly
49
54
data-testid = "selectall-checkbox"
50
55
tabIndex = { - 1 }
@@ -55,19 +60,7 @@ const SelectAll: React.FC<SelectAllProps> = React.memo(
55
60
< span data-testid = "select-all-text" > { selectAllText } </ span >
56
61
</ div >
57
62
) ;
58
- } ,
59
- areEqual
60
- ) ;
61
-
62
- SelectAll . displayName = 'Picky(SelectAll)' ;
63
-
64
- function areEqual ( prevProps : SelectAllProps , nextProps : SelectAllProps ) {
65
- return (
66
- prevProps . tabIndex === nextProps . tabIndex &&
67
- prevProps . disabled === nextProps . disabled &&
68
- prevProps . allSelected === nextProps . allSelected &&
69
- prevProps . selectAllText === nextProps . selectAllText &&
70
- prevProps . visible === nextProps . visible
71
- ) ;
63
+ }
72
64
}
65
+
73
66
export { SelectAll } ;
0 commit comments