@@ -4,23 +4,14 @@ import Cell from '../Cell';
44import TableContext from '../context/TableContext' ;
55import BodyContext from '../context/BodyContext' ;
66import { 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' ;
168import ExpandedRow from './ExpandedRow' ;
179
1810export interface BodyRowProps < RecordType > {
1911 record : RecordType ;
2012 index : number ;
2113 className ?: string ;
2214 style ?: React . CSSProperties ;
23- stickyOffsets : StickyOffsets ;
2415 recordKey : Key ;
2516 expandedKeys : Set < Key > ;
2617 rowComponent : CustomizeComponent ;
@@ -37,19 +28,19 @@ function BodyRow<RecordType extends { children?: RecordType[] }>(props: BodyRowP
3728 const {
3829 className,
3930 style,
40- stickyOffsets,
4131 record,
4232 index,
4333 rowKey,
4434 getRowKey,
4535 rowExpandable,
36+ expandedKeys,
4637 onRow,
4738 indent = 0 ,
4839 rowComponent : RowComponent ,
4940 cellComponent,
5041 childrenColumnName,
5142 } = props ;
52- const { prefixCls, direction } = React . useContext ( TableContext ) ;
43+ const { prefixCls, fixedInfoList } = React . useContext ( TableContext ) ;
5344 const {
5445 fixHeader,
5546 fixColumn,
@@ -68,23 +59,19 @@ function BodyRow<RecordType extends { children?: RecordType[] }>(props: BodyRowP
6859 } = React . useContext ( BodyContext ) ;
6960 const [ expandRended , setExpandRended ] = React . useState ( false ) ;
7061
71- const expanded = props . expandedKeys . has ( props . recordKey ) ;
62+ const expanded = expandedKeys && expandedKeys . has ( props . recordKey ) ;
7263
7364 React . useEffect ( ( ) => {
7465 if ( expanded ) {
7566 setExpandRended ( true ) ;
7667 }
7768 } , [ expanded ] ) ;
7869
79- // Move to Body to enhance performance
80- const fixedInfoList = flattenColumns . map ( ( column , colIndex ) =>
81- getCellFixedInfo ( colIndex , colIndex , flattenColumns , stickyOffsets , direction ) ,
82- ) ;
83-
8470 const rowSupportExpand = expandableType === 'row' && ( ! rowExpandable || rowExpandable ( record ) ) ;
8571 // Only when row is not expandable and `children` exist in record
8672 const nestExpandable = expandableType === 'nest' ;
87- const hasNestChildren = childrenColumnName in record && record [ childrenColumnName ] ;
73+ const hasNestChildren =
74+ childrenColumnName && childrenColumnName in record && record [ childrenColumnName ] ;
8875 const mergedExpandable = rowSupportExpand || nestExpandable ;
8976
9077 // =========================== onRow ===========================
0 commit comments