From dea4c2ca8e7cdb733409c2affcd314049733b129 Mon Sep 17 00:00:00 2001 From: Krzysztof Magiera Date: Wed, 28 Oct 2015 12:37:30 -0700 Subject: [PATCH] Use onLayout in listview instead of calling measure for every scroll event. Reviewed By: sahrens Differential Revision: D2590497 fb-gh-sync-id: 42a8f97dcb43b3a59ba3f0a008fb363f8e8c7200 --- Libraries/CustomComponents/ListView/ListView.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Libraries/CustomComponents/ListView/ListView.js b/Libraries/CustomComponents/ListView/ListView.js index 98cf211d0..f4d4240b9 100644 --- a/Libraries/CustomComponents/ListView/ListView.js +++ b/Libraries/CustomComponents/ListView/ListView.js @@ -406,6 +406,7 @@ var ListView = React.createClass({ // component's original ref instead of clobbering it return React.cloneElement(renderScrollComponent(props), { ref: SCROLLVIEW_REF, + onLayout: this._setScrollVisibleLength, }, header, bodyComponents, footer); }, @@ -424,11 +425,6 @@ var ListView = React.createClass({ logError, this._setScrollContentLength ); - RCTUIManager.measureLayoutRelativeToParent( - React.findNodeHandle(scrollComponent), - logError, - this._setScrollVisibleLength - ); // RCTScrollViewManager.calculateChildFrames is not available on // every platform @@ -444,7 +440,8 @@ var ListView = React.createClass({ height : width; }, - _setScrollVisibleLength: function(left, top, width, height) { + _setScrollVisibleLength: function(event) { + var {width, height} = event.nativeEvent.layout; this.scrollProperties.visibleLength = !this.props.horizontal ? height : width; this._updateVisibleRows();