@@ -6,6 +6,7 @@ import devRenderTimes from '../hooks/useRenderTimes';
66import useRowInfo from '../hooks/useRowInfo' ;
77import type { ColumnType , CustomizeComponent , GetRowKey } from '../interface' ;
88import ExpandedRow from './ExpandedRow' ;
9+ import { computedExpandedClassName } from '@/utils/expandUtil' ;
910
1011export interface BodyRowProps < RecordType > {
1112 record : RecordType ;
@@ -126,15 +127,7 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
126127
127128 // 若没有 expandedRowRender 参数, 将使用 baseRowNode 渲染 Children
128129 // 此时如果 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 ) ;
138131
139132 // ======================== Base tr row ========================
140133 const baseRowNode = (
@@ -147,13 +140,10 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
147140 `${ prefixCls } -row-level-${ indent } ` ,
148141 rowProps ?. className ,
149142 {
150- [ computedExpandedRowClassName ] : indent >= 1 ,
143+ [ expandedClsName ] : indent >= 1 ,
151144 } ,
152145 ) }
153- style = { {
154- ...style ,
155- ...rowProps ?. style ,
156- } }
146+ style = { { ...style , ...rowProps ?. style } }
157147 >
158148 { flattenColumns . map ( ( column : ColumnType < RecordType > , colIndex ) => {
159149 const { render, dataIndex, className : columnClassName } = column ;
@@ -201,7 +191,7 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
201191 className = { classNames (
202192 `${ prefixCls } -expanded-row` ,
203193 `${ prefixCls } -expanded-row-level-${ indent + 1 } ` ,
204- computedExpandedRowClassName ,
194+ expandedClsName ,
205195 ) }
206196 prefixCls = { prefixCls }
207197 component = { RowComponent }
0 commit comments