Skip to content

Commit

Permalink
Don't automatically render more rows when dataSource updates
Browse files Browse the repository at this point in the history
Reviewed By: sahrens

Differential Revision: D2875678

fb-gh-sync-id: c10e2c65c133d01245ac134170b25cb93377f97b
  • Loading branch information
javache authored and facebook-github-bot-4 committed Feb 5, 2016
1 parent fa2b531 commit d2ab6ca
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions Libraries/CustomComponents/ListView/ListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ var StaticRenderer = require('StaticRenderer');
var TimerMixin = require('react-timer-mixin');

var isEmpty = require('isEmpty');
var logError = require('logError');
var merge = require('merge');

var PropTypes = React.PropTypes;
Expand Down Expand Up @@ -292,26 +291,20 @@ var ListView = React.createClass({
},

componentWillReceiveProps: function(nextProps) {
if (this.props.dataSource !== nextProps.dataSource) {
if (this.props.dataSource !== nextProps.dataSource ||
this.props.initialListSize !== nextProps.initialListSize) {
this.setState((state, props) => {
this._prevRenderedRowsCount = 0;
return {
curRenderedRowsCount: Math.min(
state.curRenderedRowsCount + props.pageSize,
Math.max(
state.curRenderedRowsCount,
props.initialListSize
),
props.dataSource.getRowCount()
),
};
});
}
if (this.props.initialListSize !== nextProps.initialListSize) {
this.setState((state, props) => {
return {
curRenderedRowsCount: Math.max(
state.curRenderedRowsCount,
props.initialListSize
),
};
});
}, () => this._renderMoreRowsIfNeeded());
}
},

Expand Down

0 comments on commit d2ab6ca

Please sign in to comment.