Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ListView] Update curRenderedRowsCount when data source changes #1612

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 24 additions & 16 deletions Libraries/CustomComponents/ListView/ListView.js
Expand Up @@ -262,7 +262,16 @@ var ListView = React.createClass({

componentWillReceiveProps: function(nextProps) {
if (this.props.dataSource !== nextProps.dataSource) {
this.setState({prevRenderedRowsCount: 0});
this.setState((state, props) => {
var rowsToRender = Math.min(
state.curRenderedRowsCount + props.pageSize,
props.dataSource.getRowCount()
);
return {
prevRenderedRowsCount: 0,
curRenderedRowsCount: rowsToRender,
};
});
}
},

Expand Down Expand Up @@ -412,22 +421,21 @@ var ListView = React.createClass({
},

_pageInNewRows: function() {
var rowsToRender = Math.min(
this.state.curRenderedRowsCount + this.props.pageSize,
this.props.dataSource.getRowCount()
);
this.setState(
{
prevRenderedRowsCount: this.state.curRenderedRowsCount,
this.setState((state, props) => {
var rowsToRender = Math.min(
state.curRenderedRowsCount + props.pageSize,
props.dataSource.getRowCount()
);
return {
prevRenderedRowsCount: state.curRenderedRowsCount,
curRenderedRowsCount: rowsToRender
},
() => {
this._measureAndUpdateScrollProps();
this.setState({
prevRenderedRowsCount: this.state.curRenderedRowsCount,
});
}
);
};
}, () => {
this._measureAndUpdateScrollProps();
this.setState(state => ({
prevRenderedRowsCount: state.curRenderedRowsCount,
}));
});
},

_getDistanceFromEnd: function(scrollProperties) {
Expand Down