From 203a82e90a1c8cc209ae287e4e3eb4dcb34ab3f1 Mon Sep 17 00:00:00 2001 From: Marshall Roch Date: Tue, 25 Jan 2022 14:56:39 -0800 Subject: [PATCH] fix flow suppression in VirtualizedList Summary: flow 0.146 became more conservative about refinement invalidation, no longer accepting that `this.props.onViewableItemsChanged` is truthy. this was suppressed at the time. instead, we can assign to a const to restore typechecking. Changelog: [Internal] Reviewed By: motiz88 Differential Revision: D33743126 fbshipit-source-id: 0b1f0b83c2fe812e88b027c3b1d3d8aca7b09277 --- Libraries/Lists/VirtualizedList.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 76f46d7428c..6de43b77c46 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -703,12 +703,14 @@ class VirtualizedList extends React.PureComponent { onViewableItemsChanged: pair.onViewableItemsChanged, }), ); - } else if (this.props.onViewableItemsChanged) { - this._viewabilityTuples.push({ - viewabilityHelper: new ViewabilityHelper(this.props.viewabilityConfig), - // $FlowFixMe[incompatible-call] - onViewableItemsChanged: this.props.onViewableItemsChanged, - }); + } else { + const {onViewableItemsChanged, viewabilityConfig} = this.props; + if (onViewableItemsChanged) { + this._viewabilityTuples.push({ + viewabilityHelper: new ViewabilityHelper(viewabilityConfig), + onViewableItemsChanged: onViewableItemsChanged, + }); + } } let initialState = {