diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 05c15e8d4..37c574f05 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -1112,28 +1112,40 @@ class VirtualizedList extends React.PureComponent { }; measureLayoutRelativeToContainingList(): void { - UIManager.measureLayout( - ReactNative.findNodeHandle(this), - ReactNative.findNodeHandle( - this.context.virtualizedList.getOutermostParentListRef(), - ), - error => { - console.warn( - "VirtualizedList: Encountered an error while measuring a list's" + - ' offset from its containing VirtualizedList.', - ); - }, - (x, y, width, height) => { - this._offsetFromParentVirtualizedList = this._selectOffset({x, y}); - this._scrollMetrics.contentLength = this._selectLength({width, height}); + // TODO (T35574538): findNodeHandle sometimes crashes with "Unable to find + // node on an unmounted component" during scrolling + try { + UIManager.measureLayout( + ReactNative.findNodeHandle(this), + ReactNative.findNodeHandle( + this.context.virtualizedList.getOutermostParentListRef(), + ), + error => { + console.warn( + "VirtualizedList: Encountered an error while measuring a list's" + + ' offset from its containing VirtualizedList.', + ); + }, + (x, y, width, height) => { + this._offsetFromParentVirtualizedList = this._selectOffset({x, y}); + this._scrollMetrics.contentLength = this._selectLength({ + width, + height, + }); - const scrollMetrics = this._convertParentScrollMetrics( - this.context.virtualizedList.getScrollMetrics(), - ); - this._scrollMetrics.visibleLength = scrollMetrics.visibleLength; - this._scrollMetrics.offset = scrollMetrics.offset; - }, - ); + const scrollMetrics = this._convertParentScrollMetrics( + this.context.virtualizedList.getScrollMetrics(), + ); + this._scrollMetrics.visibleLength = scrollMetrics.visibleLength; + this._scrollMetrics.offset = scrollMetrics.offset; + }, + ); + } catch (error) { + console.warn( + 'measureLayoutRelativeToContainingList threw an error', + error.stack, + ); + } } _onLayout = (e: Object) => {