@@ -3,6 +3,7 @@ import {Skeleton} from '@gravity-ui/uikit';
3
3
import { DEFAULT_ALIGN , DEFAULT_RESIZEABLE } from './constants' ;
4
4
import { b } from './shared' ;
5
5
import type { AlignType , Column , GetRowClassName } from './types' ;
6
+ import { typedMemo } from './utils' ;
6
7
7
8
interface TableCellProps {
8
9
height : number ;
@@ -38,19 +39,18 @@ const TableRowCell = ({
38
39
39
40
interface LoadingTableRowProps < T > {
40
41
columns : Column < T > [ ] ;
41
- index : number ;
42
42
height : number ;
43
43
}
44
44
45
- export const LoadingTableRow = < T , > ( { index , columns, height} : LoadingTableRowProps < T > ) => {
45
+ export const LoadingTableRow = typedMemo ( function < T > ( { columns, height} : LoadingTableRowProps < T > ) {
46
46
return (
47
47
< tr className = { b ( 'row' , { loading : true } ) } >
48
48
{ columns . map ( ( column ) => {
49
49
const resizeable = column . resizeable ?? DEFAULT_RESIZEABLE ;
50
50
51
51
return (
52
52
< TableRowCell
53
- key = { ` ${ column . name } ${ index } ` }
53
+ key = { column . name }
54
54
height = { height }
55
55
width = { column . width }
56
56
align = { column . align }
@@ -66,17 +66,16 @@ export const LoadingTableRow = <T,>({index, columns, height}: LoadingTableRowPro
66
66
} ) }
67
67
</ tr >
68
68
) ;
69
- } ;
69
+ } ) ;
70
70
71
71
interface TableRowProps < T > {
72
72
columns : Column < T > [ ] ;
73
- index : number ;
74
73
row : T ;
75
74
height : number ;
76
75
getRowClassName ?: GetRowClassName < T > ;
77
76
}
78
77
79
- export const TableRow = < T , > ( { row, index , columns, getRowClassName, height} : TableRowProps < T > ) => {
78
+ export const TableRow = < T , > ( { row, columns, getRowClassName, height} : TableRowProps < T > ) => {
80
79
const additionalClassName = getRowClassName ?.( row ) ;
81
80
82
81
return (
@@ -86,14 +85,14 @@ export const TableRow = <T,>({row, index, columns, getRowClassName, height}: Tab
86
85
87
86
return (
88
87
< TableRowCell
89
- key = { ` ${ column . name } ${ index } ` }
88
+ key = { column . name }
90
89
height = { height }
91
90
width = { column . width }
92
91
align = { column . align }
93
92
className = { column . className }
94
93
resizeable = { resizeable }
95
94
>
96
- { column . render ( { row, index } ) }
95
+ { column . render ( { row} ) }
97
96
</ TableRowCell >
98
97
) ;
99
98
} ) }
0 commit comments