@@ -78,6 +78,10 @@ interface ListState<T> {
78
78
* Only used when turn virtual list to raw list
79
79
*/
80
80
cacheScroll ?: RelativeScroll ;
81
+ /**
82
+ * Cache `data.length` to use for `disabled` status.
83
+ */
84
+ itemCount : number ;
81
85
}
82
86
83
87
/**
@@ -138,9 +142,20 @@ class List<T> extends React.Component<ListProps<T>, ListState<T>> {
138
142
endIndex : 0 ,
139
143
startItemTop : 0 ,
140
144
isVirtual : requireVirtual ( props . height , props . itemHeight , props . data . length ) ,
145
+ itemCount : props . data . length ,
141
146
} ;
142
147
}
143
148
149
+ static getDerivedStateFromProps ( nextProps : ListProps < any > ) {
150
+ if ( ! nextProps . disabled ) {
151
+ return {
152
+ itemCount : nextProps . data . length ,
153
+ } ;
154
+ }
155
+
156
+ return null ;
157
+ }
158
+
144
159
/**
145
160
* Phase 1: Initial should sync with default scroll top
146
161
*/
@@ -524,7 +539,7 @@ class List<T> extends React.Component<ListProps<T>, ListState<T>> {
524
539
} ;
525
540
526
541
public render ( ) {
527
- const { isVirtual } = this . state ;
542
+ const { isVirtual, itemCount } = this . state ;
528
543
const {
529
544
style,
530
545
component : Component = 'div' ,
@@ -559,7 +574,7 @@ class List<T> extends React.Component<ListProps<T>, ListState<T>> {
559
574
} ;
560
575
561
576
const { status, startIndex, endIndex, startItemTop } = this . state ;
562
- const contentHeight = data . length * itemHeight * ITEM_SCALE_RATE ;
577
+ const contentHeight = itemCount * itemHeight * ITEM_SCALE_RATE ;
563
578
564
579
return (
565
580
< Component style = { mergedStyle } { ...restProps } onScroll = { this . onScroll } ref = { this . listRef } >
0 commit comments