[fix] ListView updates rows when dataSource changes

Close #295
This commit is contained in:
Gethin Webster
2016-12-22 14:18:37 +01:00
committed by Nicolas Gallagher
parent 32f454de66
commit 04e3c23e67
+14
View File
@@ -59,6 +59,20 @@ class ListView extends Component {
});
}
componentWillReceiveProps(nextProps: Object) {
if (this.props.dataSource !== nextProps.dataSource || this.props.initialListSize !== nextProps.initialListSize) {
this.setState((state, props) => {
this._prevRenderedRowsCount = 0;
return {
curRenderedRowsCount: Math.min(
Math.max(state.curRenderedRowsCount, props.initialListSize),
props.enableEmptySections ? props.dataSource.getRowAndSectionCount() : props.dataSource.getRowCount()
)
};
}, () => this._renderMoreRowsIfNeeded());
}
}
componentDidUpdate() {
requestAnimationFrame(() => {
this._measureAndUpdateScrollProps();