@@ -4,23 +4,14 @@ import Cell from '../Cell';
4
4
import TableContext from '../context/TableContext' ;
5
5
import BodyContext from '../context/BodyContext' ;
6
6
import { getColumnsKey } from '../utils/valueUtil' ;
7
- import {
8
- ColumnType ,
9
- StickyOffsets ,
10
- CustomizeComponent ,
11
- GetComponentProps ,
12
- Key ,
13
- GetRowKey ,
14
- } from '../interface' ;
15
- import { getCellFixedInfo } from '../utils/fixUtil' ;
7
+ import { ColumnType , CustomizeComponent , GetComponentProps , Key , GetRowKey } from '../interface' ;
16
8
import ExpandedRow from './ExpandedRow' ;
17
9
18
10
export interface BodyRowProps < RecordType > {
19
11
record : RecordType ;
20
12
index : number ;
21
13
className ?: string ;
22
14
style ?: React . CSSProperties ;
23
- stickyOffsets : StickyOffsets ;
24
15
recordKey : Key ;
25
16
expandedKeys : Set < Key > ;
26
17
rowComponent : CustomizeComponent ;
@@ -37,19 +28,19 @@ function BodyRow<RecordType extends { children?: RecordType[] }>(props: BodyRowP
37
28
const {
38
29
className,
39
30
style,
40
- stickyOffsets,
41
31
record,
42
32
index,
43
33
rowKey,
44
34
getRowKey,
45
35
rowExpandable,
36
+ expandedKeys,
46
37
onRow,
47
38
indent = 0 ,
48
39
rowComponent : RowComponent ,
49
40
cellComponent,
50
41
childrenColumnName,
51
42
} = props ;
52
- const { prefixCls, direction } = React . useContext ( TableContext ) ;
43
+ const { prefixCls, fixedInfoList } = React . useContext ( TableContext ) ;
53
44
const {
54
45
fixHeader,
55
46
fixColumn,
@@ -68,23 +59,19 @@ function BodyRow<RecordType extends { children?: RecordType[] }>(props: BodyRowP
68
59
} = React . useContext ( BodyContext ) ;
69
60
const [ expandRended , setExpandRended ] = React . useState ( false ) ;
70
61
71
- const expanded = props . expandedKeys . has ( props . recordKey ) ;
62
+ const expanded = expandedKeys && expandedKeys . has ( props . recordKey ) ;
72
63
73
64
React . useEffect ( ( ) => {
74
65
if ( expanded ) {
75
66
setExpandRended ( true ) ;
76
67
}
77
68
} , [ expanded ] ) ;
78
69
79
- // Move to Body to enhance performance
80
- const fixedInfoList = flattenColumns . map ( ( column , colIndex ) =>
81
- getCellFixedInfo ( colIndex , colIndex , flattenColumns , stickyOffsets , direction ) ,
82
- ) ;
83
-
84
70
const rowSupportExpand = expandableType === 'row' && ( ! rowExpandable || rowExpandable ( record ) ) ;
85
71
// Only when row is not expandable and `children` exist in record
86
72
const nestExpandable = expandableType === 'nest' ;
87
- const hasNestChildren = childrenColumnName in record && record [ childrenColumnName ] ;
73
+ const hasNestChildren =
74
+ childrenColumnName && childrenColumnName in record && record [ childrenColumnName ] ;
88
75
const mergedExpandable = rowSupportExpand || nestExpandable ;
89
76
90
77
// =========================== onRow ===========================
0 commit comments