Skip to content

Commit

Permalink
fix listview inefficiency for tail-fetching scenarios (part2)
Browse files Browse the repository at this point in the history
Reviewed By: sahrens

Differential Revision: D2775293

fb-gh-sync-id: a18a2fd6f64b5c979267a21ecdac8c3d97d9e007
  • Loading branch information
olinotteghem authored and facebook-github-bot-8 committed Dec 20, 2015
1 parent 97fe0ea commit 174d37c
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions Libraries/CustomComponents/ListView/ListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ var ListView = React.createClass({
getInitialState: function() {
return {
curRenderedRowsCount: this.props.initialListSize,
prevRenderedRowsCount: 0,
highlightedRow: {},
};
},
Expand All @@ -266,6 +265,7 @@ var ListView = React.createClass({
};
this._childFrames = [];
this._visibleRows = {};
this._prevRenderedRowsCount = 0;
},

componentDidMount: function() {
Expand All @@ -283,8 +283,8 @@ var ListView = React.createClass({
state.curRenderedRowsCount + props.pageSize,
props.dataSource.getRowCount()
);
this._prevRenderedRowsCount = 0;
return {
prevRenderedRowsCount: 0,
curRenderedRowsCount: rowsToRender,
};
});
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -427,7 +427,7 @@ var ListView = React.createClass({
RCTScrollViewManager && RCTScrollViewManager.calculateChildFrames &&
RCTScrollViewManager.calculateChildFrames(
React.findNodeHandle(scrollComponent),
this._updateChildFrames,
this._updateVisibleRows,
);
},

Expand Down Expand Up @@ -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 &&
Expand Down Expand Up @@ -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;
});
},

Expand Down

0 comments on commit 174d37c

Please sign in to comment.