@@ -6,6 +6,7 @@ import devRenderTimes from '../hooks/useRenderTimes';
6
6
import useRowInfo from '../hooks/useRowInfo' ;
7
7
import type { ColumnType , CustomizeComponent , GetRowKey } from '../interface' ;
8
8
import ExpandedRow from './ExpandedRow' ;
9
+ import { computedExpandedClassName } from '@/utils/expandUtil' ;
9
10
10
11
export interface BodyRowProps < RecordType > {
11
12
record : RecordType ;
@@ -126,15 +127,7 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
126
127
127
128
// 若没有 expandedRowRender 参数, 将使用 baseRowNode 渲染 Children
128
129
// 此时如果 level > 1 则说明是 expandedRow, 一样需要附加 computedExpandedRowClassName
129
- const computedExpandedRowClassName = React . useMemo < string > ( ( ) => {
130
- if ( typeof expandedRowClassName === 'string' ) {
131
- return expandedRowClassName ;
132
- }
133
- if ( typeof expandedRowClassName === 'function' ) {
134
- return expandedRowClassName ( record , index , indent ) ;
135
- }
136
- return '' ;
137
- } , [ expandedRowClassName , record , index , indent ] ) ;
130
+ const expandedClsName = computedExpandedClassName ( expandedRowClassName , record , index , indent ) ;
138
131
139
132
// ======================== Base tr row ========================
140
133
const baseRowNode = (
@@ -147,13 +140,10 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
147
140
`${ prefixCls } -row-level-${ indent } ` ,
148
141
rowProps ?. className ,
149
142
{
150
- [ computedExpandedRowClassName ] : indent >= 1 ,
143
+ [ expandedClsName ] : indent >= 1 ,
151
144
} ,
152
145
) }
153
- style = { {
154
- ...style ,
155
- ...rowProps ?. style ,
156
- } }
146
+ style = { { ...style , ...rowProps ?. style } }
157
147
>
158
148
{ flattenColumns . map ( ( column : ColumnType < RecordType > , colIndex ) => {
159
149
const { render, dataIndex, className : columnClassName } = column ;
@@ -201,7 +191,7 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
201
191
className = { classNames (
202
192
`${ prefixCls } -expanded-row` ,
203
193
`${ prefixCls } -expanded-row-level-${ indent + 1 } ` ,
204
- computedExpandedRowClassName ,
194
+ expandedClsName ,
205
195
) }
206
196
prefixCls = { prefixCls }
207
197
component = { RowComponent }
0 commit comments