File tree 1 file changed +11
-7
lines changed
1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -279,13 +279,17 @@ export function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>) {
279
279
const changedRecord = heights . getRecord ( ) ;
280
280
if ( changedRecord . size === 1 ) {
281
281
const recordKey = Array . from ( changedRecord ) [ 0 ] ;
282
- const startIndexKey = getKey ( mergedData [ start ] ) ;
283
- if ( startIndexKey === recordKey ) {
284
- const realStartHeight = heights . get ( recordKey ) ;
285
- const diffHeight = realStartHeight - itemHeight ;
286
- syncScrollTop ( ( ori ) => {
287
- return ori + diffHeight ;
288
- } ) ;
282
+ // Quick switch data may cause `start` not in `mergedData` anymore
283
+ const startItem = mergedData [ start ] ;
284
+ if ( startItem ) {
285
+ const startIndexKey = getKey ( startItem ) ;
286
+ if ( startIndexKey === recordKey ) {
287
+ const realStartHeight = heights . get ( recordKey ) ;
288
+ const diffHeight = realStartHeight - itemHeight ;
289
+ syncScrollTop ( ( ori ) => {
290
+ return ori + diffHeight ;
291
+ } ) ;
292
+ }
289
293
}
290
294
}
291
295
You can’t perform that action at this time.
0 commit comments