Fix corner case bug in ListView

Reviewed By: sahrens

Differential Revision: D2802885

fb-gh-sync-id: e4bb82e3c63ded2af46f5b078b712636d3afa156
This commit is contained in:
Olivier Notteghem 2016-01-06 19:15:16 -08:00 committed by facebook-github-bot-7
parent bd3ef4315f
commit b75c939d59
1 changed files with 14 additions and 5 deletions

View File

@ -294,13 +294,22 @@ var ListView = React.createClass({
componentWillReceiveProps: function(nextProps) {
if (this.props.dataSource !== nextProps.dataSource) {
this.setState((state, props) => {
var rowsToRender = Math.min(
state.curRenderedRowsCount + props.pageSize,
props.dataSource.getRowCount()
);
this._prevRenderedRowsCount = 0;
return {
curRenderedRowsCount: rowsToRender,
curRenderedRowsCount: Math.min(
state.curRenderedRowsCount + props.pageSize,
props.dataSource.getRowCount()
),
};
});
}
if (this.props.initialListSize !== nextProps.initialListSize) {
this.setState((state, props) => {
return {
curRenderedRowsCount: Math.max(
state.curRenderedRowsCount,
props.initialListSize
),
};
});
}