@@ -61,10 +61,10 @@ const ListComponent = forwardRef(function (
61
61
const treeRef = useRef ( new NumberTree ( ) ) ;
62
62
const tableRef = useRef < HTMLDivElement > ( null ) ;
63
63
const cacheRef = useRef < { [ index : number ] : number } > ( { } ) ;
64
+ const defaultSizeRef = useRef ( rowHeight || DEFAULT_ROW_HEIGHT ) ;
64
65
const { dispatch, uuid, columns, minColumnWidth, fixedWidth, remainingCols, pixelWidths } =
65
66
useContext ( TableContext ) ;
66
67
const [ useRowWidth , setUseRowWidth ] = useState ( true ) ;
67
- const [ defaultSize , setDefaultSize ] = useState ( rowHeight || DEFAULT_ROW_HEIGHT ) ;
68
68
69
69
// constants
70
70
const hasFooter = useMemo ( ( ) => {
@@ -107,17 +107,18 @@ const ListComponent = forwardRef(function (
107
107
const row = typeof queryParam === "number" ? findRowByUuidAndKey ( uuid , key ) : queryParam ;
108
108
109
109
if ( ! row ) {
110
- return cacheRef . current [ dataIndex ] || defaultSize ;
110
+ return cacheRef . current [ dataIndex ] || defaultSizeRef . current ;
111
111
}
112
112
113
113
const arr = [ ...row . children ] . slice ( rowHeight ? 1 : 0 ) as HTMLElement [ ] ;
114
- const res = arr . reduce ( ( pv , c ) => pv + c . offsetHeight , rowHeight || 0 ) || defaultSize ;
114
+ const res =
115
+ arr . reduce ( ( pv , c ) => pv + c . offsetHeight , rowHeight || 0 ) || defaultSizeRef . current ;
115
116
116
117
// update the calculated height ref
117
118
cacheRef . current [ dataIndex ] = res ;
118
119
return res ;
119
120
} ,
120
- [ uuid , data , rowHeight , defaultSize , generateKeyFromRow ]
121
+ [ uuid , data , rowHeight , generateKeyFromRow ]
121
122
) ;
122
123
123
124
const updatePixelWidths = useCallback ( ( ) => {
@@ -275,10 +276,7 @@ const ListComponent = forwardRef(function (
275
276
}
276
277
} ) ;
277
278
278
- const median = treeRef . current . getMedian ( ) ;
279
- if ( median && defaultSize !== median ) {
280
- setDefaultSize ( median ) ;
281
- }
279
+ defaultSizeRef . current = treeRef . current . getMedian ( ) ;
282
280
} }
283
281
itemData = { {
284
282
rows : data ,
0 commit comments