Skip to content

Commit 24a7477

Browse files
authored
Merge pull request #46 from janicduplessis/@janic/0.71.2-patch
Cherry pick VirtualizedList fixes
2 parents a96968f + 3bf2583 commit 24a7477

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Libraries/Lists/VirtualizedList.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,6 @@ export default class VirtualizedList extends StateSafePureComponent<
613613
const onEndReachedThreshold = onEndReachedThresholdOrDefault(
614614
props.onEndReachedThreshold,
615615
);
616-
this._updateViewableItems(props, cellsAroundViewport);
617616

618617
const {contentLength, offset, visibleLength} = this._scrollMetrics;
619618
const distanceFromEnd = contentLength - visibleLength - offset;
@@ -1125,7 +1124,7 @@ export default class VirtualizedList extends StateSafePureComponent<
11251124
}
11261125
}
11271126

1128-
componentDidUpdate(prevProps: Props) {
1127+
componentDidUpdate(prevProps: Props, prevState: State) {
11291128
const {data, extraData} = this.props;
11301129
if (data !== prevProps.data || extraData !== prevProps.extraData) {
11311130
// clear the viewableIndices cache to also trigger
@@ -1147,6 +1146,15 @@ export default class VirtualizedList extends StateSafePureComponent<
11471146
if (hiPriInProgress) {
11481147
this._hiPriInProgress = false;
11491148
}
1149+
1150+
// Make sure to cancel any pending updates if maintainVisibleContentPositionAdjustment
1151+
// changed since they are now invalid.
1152+
if (
1153+
prevState.maintainVisibleContentPositionAdjustment !==
1154+
this.state.maintainVisibleContentPositionAdjustment
1155+
) {
1156+
this._updateCellsToRenderBatcher.dispose({abort: true});
1157+
}
11501158
}
11511159

11521160
_averageCellLength = 0;
@@ -1787,6 +1795,8 @@ export default class VirtualizedList extends StateSafePureComponent<
17871795
};
17881796

17891797
_updateCellsToRender = () => {
1798+
this._updateViewableItems(this.props, this.state.cellsAroundViewport);
1799+
17901800
this.setState((state, props) => {
17911801
const cellsAroundViewport = this._adjustCellsAroundViewport(
17921802
props,

0 commit comments

Comments
 (0)