From 515cc6f596ce345fc7591776935d1c56f09cb664 Mon Sep 17 00:00:00 2001 From: Eli White Date: Fri, 11 Oct 2019 09:44:48 -0700 Subject: [PATCH] Fix some $FlowFixMe in VirtualizedList Summary: Fixing up some of the FlowFixMes in VirtualizedList Changelog: [Internal] Reviewed By: zackargyle Differential Revision: D17839611 fbshipit-source-id: c763a799efca63fd7110cfaed87afde80995b8aa --- Libraries/Lists/VirtualizedList.js | 40 ++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 24367f8b836..e5963980f56 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -314,9 +314,11 @@ class VirtualizedList extends React.PureComponent { this._footerLength - this._scrollMetrics.visibleLength, ); - /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment - * suppresses an error when upgrading Flow's support for React. To see the - * error delete this comment and run Flow. */ + + if (this._scrollRef == null) { + return; + } + this._scrollRef.scrollTo( this.props.horizontal ? {x: offset, animated} : {y: offset, animated}, ); @@ -364,9 +366,11 @@ class VirtualizedList extends React.PureComponent { (viewPosition || 0) * (this._scrollMetrics.visibleLength - frame.length), ) - (viewOffset || 0); - /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment - * suppresses an error when upgrading Flow's support for React. To see the - * error delete this comment and run Flow. */ + + if (this._scrollRef == null) { + return; + } + this._scrollRef.scrollTo( horizontal ? {x: offset, animated} : {y: offset, animated}, ); @@ -402,9 +406,11 @@ class VirtualizedList extends React.PureComponent { */ scrollToOffset(params: {animated?: ?boolean, offset: number}) { const {animated, offset} = params; - /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment - * suppresses an error when upgrading Flow's support for React. To see the - * error delete this comment and run Flow. */ + + if (this._scrollRef == null) { + return; + } + this._scrollRef.scrollTo( this.props.horizontal ? {x: offset, animated} : {y: offset, animated}, ); @@ -421,9 +427,10 @@ class VirtualizedList extends React.PureComponent { } flashScrollIndicators() { - /* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This comment - * suppresses an error when upgrading Flow's support for React. To see the - * error delete this comment and run Flow. */ + if (this._scrollRef == null) { + return; + } + this._scrollRef.flashScrollIndicators(); } @@ -1019,13 +1026,10 @@ class VirtualizedList extends React.PureComponent { ? this.props.invertStickyHeaders : this.props.inverted, stickyHeaderIndices, + style: inversionStyle + ? [inversionStyle, this.props.style] + : this.props.style, }; - if (inversionStyle) { - /* $FlowFixMe(>=0.70.0 site=react_native_fb) This comment suppresses an - * error found when Flow v0.70 was deployed. To see the error delete - * this comment and run Flow. */ - scrollProps.style = [inversionStyle, this.props.style]; - } this._hasMore = this.state.last < this.props.getItemCount(this.props.data) - 1;