mirror of
https://github.com/status-im/react-native.git
synced 2025-02-05 06:04:15 +00:00
fix listview inefficiency for tail-fetching scenarios (part2)
Reviewed By: sahrens Differential Revision: D2775293 fb-gh-sync-id: a18a2fd6f64b5c979267a21ecdac8c3d97d9e007
This commit is contained in:
parent
97fe0eae6b
commit
174d37c1d9
@ -248,7 +248,6 @@ var ListView = React.createClass({
|
||||
getInitialState: function() {
|
||||
return {
|
||||
curRenderedRowsCount: this.props.initialListSize,
|
||||
prevRenderedRowsCount: 0,
|
||||
highlightedRow: {},
|
||||
};
|
||||
},
|
||||
@ -266,6 +265,7 @@ var ListView = React.createClass({
|
||||
};
|
||||
this._childFrames = [];
|
||||
this._visibleRows = {};
|
||||
this._prevRenderedRowsCount = 0;
|
||||
},
|
||||
|
||||
componentDidMount: function() {
|
||||
@ -283,8 +283,8 @@ var ListView = React.createClass({
|
||||
state.curRenderedRowsCount + props.pageSize,
|
||||
props.dataSource.getRowCount()
|
||||
);
|
||||
this._prevRenderedRowsCount = 0;
|
||||
return {
|
||||
prevRenderedRowsCount: 0,
|
||||
curRenderedRowsCount: rowsToRender,
|
||||
};
|
||||
});
|
||||
@ -321,7 +321,7 @@ var ListView = React.createClass({
|
||||
}
|
||||
|
||||
if (this.props.renderSectionHeader) {
|
||||
var shouldUpdateHeader = rowCount >= this.state.prevRenderedRowsCount &&
|
||||
var shouldUpdateHeader = rowCount >= this._prevRenderedRowsCount &&
|
||||
dataSource.sectionHeaderShouldUpdate(sectionIdx);
|
||||
bodyComponents.push(
|
||||
<StaticRenderer
|
||||
@ -340,7 +340,7 @@ var ListView = React.createClass({
|
||||
for (var rowIdx = 0; rowIdx < rowIDs.length; rowIdx++) {
|
||||
var rowID = rowIDs[rowIdx];
|
||||
var comboID = sectionID + '_' + rowID;
|
||||
var shouldUpdateRow = rowCount >= this.state.prevRenderedRowsCount &&
|
||||
var shouldUpdateRow = rowCount >= this._prevRenderedRowsCount &&
|
||||
dataSource.rowShouldUpdate(sectionIdx, rowIdx);
|
||||
var row =
|
||||
<StaticRenderer
|
||||
@ -427,7 +427,7 @@ var ListView = React.createClass({
|
||||
RCTScrollViewManager && RCTScrollViewManager.calculateChildFrames &&
|
||||
RCTScrollViewManager.calculateChildFrames(
|
||||
React.findNodeHandle(scrollComponent),
|
||||
this._updateChildFrames,
|
||||
this._updateVisibleRows,
|
||||
);
|
||||
},
|
||||
|
||||
@ -459,10 +459,6 @@ var ListView = React.createClass({
|
||||
this._renderMoreRowsIfNeeded();
|
||||
},
|
||||
|
||||
_updateChildFrames: function(childFrames) {
|
||||
this._updateVisibleRows(childFrames);
|
||||
},
|
||||
|
||||
_maybeCallOnEndReached: function(event) {
|
||||
if (this.props.onEndReached &&
|
||||
this.scrollProperties.contentLength !== this._sentEndForContentLength &&
|
||||
@ -495,15 +491,13 @@ var ListView = React.createClass({
|
||||
state.curRenderedRowsCount + props.pageSize,
|
||||
props.dataSource.getRowCount()
|
||||
);
|
||||
this._prevRenderedRowsCount = state.curRenderedRowsCount;
|
||||
return {
|
||||
prevRenderedRowsCount: state.curRenderedRowsCount,
|
||||
curRenderedRowsCount: rowsToRender
|
||||
};
|
||||
}, () => {
|
||||
this._measureAndUpdateScrollProps();
|
||||
this.setState(state => ({
|
||||
prevRenderedRowsCount: state.curRenderedRowsCount,
|
||||
}));
|
||||
this._prevRenderedRowsCount = this.state.curRenderedRowsCount;
|
||||
});
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user