From d2ab6cabd46804a52d4e116d29767ca6a4061976 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Fri, 5 Feb 2016 11:08:59 -0800 Subject: [PATCH] Don't automatically render more rows when dataSource updates Reviewed By: sahrens Differential Revision: D2875678 fb-gh-sync-id: c10e2c65c133d01245ac134170b25cb93377f97b --- .../CustomComponents/ListView/ListView.js | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/Libraries/CustomComponents/ListView/ListView.js b/Libraries/CustomComponents/ListView/ListView.js index 2ebbf24e6..1a9bef47b 100644 --- a/Libraries/CustomComponents/ListView/ListView.js +++ b/Libraries/CustomComponents/ListView/ListView.js @@ -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; @@ -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()); } },