@@ -970,7 +970,19 @@ class VirtualizedList extends React.PureComponent<Props, State> {
970
970
tuple . viewabilityHelper . resetViewableIndices ( ) ;
971
971
} ) ;
972
972
}
973
+ // The `this._hiPriInProgress` is guaranteeing a hiPri cell update will only happen
974
+ // once per fiber update. The `_scheduleCellsToRenderUpdate` will set it to true
975
+ // if a hiPri update needs to perform. If `componentDidUpdate` is triggered with
976
+ // `this._hiPriInProgress=true`, means it's triggered by the hiPri update. The
977
+ // `_scheduleCellsToRenderUpdate` will check this condition and not perform
978
+ // another hiPri update.
979
+ const hiPriInProgress = this . _hiPriInProgress ;
973
980
this . _scheduleCellsToRenderUpdate ( ) ;
981
+ // Make sure setting `this._hiPriInProgress` back to false after `componentDidUpdate`
982
+ // is triggered with `this._hiPriInProgress = true`
983
+ if ( hiPriInProgress ) {
984
+ this . _hiPriInProgress = false ;
985
+ }
974
986
}
975
987
976
988
_averageCellLength = 0 ;
@@ -981,13 +993,14 @@ class VirtualizedList extends React.PureComponent<Props, State> {
981
993
_frames = { } ;
982
994
_footerLength = 0 ;
983
995
_hasDataChangedSinceEndReached = true ;
996
+ _hasDoneInitialScroll = false ;
984
997
_hasInteracted = false ;
985
998
_hasMore = false ;
986
999
_hasWarned = { } ;
987
- _highestMeasuredFrameIndex = 0 ;
988
1000
_headerLength = 0 ;
1001
+ _hiPriInProgress : boolean = false ; // flag to prevent infinite hiPri cell limit update
1002
+ _highestMeasuredFrameIndex = 0 ;
989
1003
_indicesToKeys : Map < number , string > = new Map ( ) ;
990
- _hasDoneInitialScroll = false ;
991
1004
_nestedChildLists : Map <
992
1005
string ,
993
1006
{ ref : ?VirtualizedList , state : ?ChildListState } ,
@@ -1411,7 +1424,10 @@ class VirtualizedList extends React.PureComponent<Props, State> {
1411
1424
// Otherwise, it would just render as many cells as it can (of zero dimension),
1412
1425
// each time through attempting to render more (limited by maxToRenderPerBatch),
1413
1426
// starving the renderer from actually laying out the objects and computing _averageCellLength.
1414
- if ( hiPri && this . _averageCellLength ) {
1427
+ // If this is triggered in an `componentDidUpdate` followed by a hiPri cellToRenderUpdate
1428
+ // We shouldn't do another hipri cellToRenderUpdate
1429
+ if ( hiPri && this . _averageCellLength && ! this . _hiPriInProgress ) {
1430
+ this . _hiPriInProgress = true ;
1415
1431
// Don't worry about interactions when scrolling quickly; focus on filling content as fast
1416
1432
// as possible.
1417
1433
this . _updateCellsToRenderBatcher . dispose ( { abort : true } ) ;
0 commit comments