Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,6 @@ export default class VirtualizedList extends StateSafePureComponent<
const onEndReachedThreshold = onEndReachedThresholdOrDefault(
props.onEndReachedThreshold,
);
this._updateViewableItems(props, cellsAroundViewport);

const {contentLength, offset, visibleLength} = this._scrollMetrics;
const distanceFromEnd = contentLength - visibleLength - offset;
Expand Down Expand Up @@ -1125,7 +1124,7 @@ export default class VirtualizedList extends StateSafePureComponent<
}
}

componentDidUpdate(prevProps: Props) {
componentDidUpdate(prevProps: Props, prevState: State) {
const {data, extraData} = this.props;
if (data !== prevProps.data || extraData !== prevProps.extraData) {
// clear the viewableIndices cache to also trigger
Expand All @@ -1147,6 +1146,15 @@ export default class VirtualizedList extends StateSafePureComponent<
if (hiPriInProgress) {
this._hiPriInProgress = false;
}

// Make sure to cancel any pending updates if maintainVisibleContentPositionAdjustment
// changed since they are now invalid.
if (
prevState.maintainVisibleContentPositionAdjustment !==
this.state.maintainVisibleContentPositionAdjustment
) {
this._updateCellsToRenderBatcher.dispose({abort: true});
}
}

_averageCellLength = 0;
Expand Down Expand Up @@ -1787,6 +1795,8 @@ export default class VirtualizedList extends StateSafePureComponent<
};

_updateCellsToRender = () => {
this._updateViewableItems(this.props, this.state.cellsAroundViewport);

this.setState((state, props) => {
const cellsAroundViewport = this._adjustCellsAroundViewport(
props,
Expand Down