File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -405,11 +405,17 @@ class List<T> extends React.Component<ListProps<T>, ListState<T>> {
405
405
*/
406
406
public collectItemHeights = ( ) => {
407
407
const { startIndex, endIndex } = this . state ;
408
+ const { data } = this . props ;
408
409
409
410
// Record here since measure item height will get warning in `render`
410
411
for ( let index = startIndex ; index <= endIndex ; index += 1 ) {
411
- const eleKey = this . getIndexKey ( index ) ;
412
- this . itemElementHeights [ eleKey ] = getNodeHeight ( this . itemElements [ eleKey ] ) ;
412
+ const item = data [ index ] ;
413
+
414
+ // Only collect exist item height
415
+ if ( item ) {
416
+ const eleKey = this . getItemKey ( item ) ;
417
+ this . itemElementHeights [ eleKey ] = getNodeHeight ( this . itemElements [ eleKey ] ) ;
418
+ }
413
419
}
414
420
} ;
415
421
You can’t perform that action at this time.
0 commit comments