From bd70cbf04242cfed99e670e0c909f143de6152ce Mon Sep 17 00:00:00 2001 From: Eli White Date: Fri, 11 Oct 2019 09:44:48 -0700 Subject: [PATCH] VirtualizedSectionList: Fix flow error about this.props.onViewableItemsChanged being null Summary: Flow complains that the function could be null or undefined even after checking that because this._convertviewable is called first and could potentially muck with the type. Here is an example in try flow: https://flow.org/try/#0CYUwxgNghgTiAEA3W8AeAueBvAZpg-ABSEB2ArgLYBGIMAlPALwB8SA9gJbB0C+A3ACgcZEmAAuHNiXg5CdTOWq1s8OGLIxpAZh4CBHHPEKoAdIYCEjeOQgQGWAfDRnCsunUE8gA Changelog: [Internal] Reviewed By: jbrown215 Differential Revision: D17863358 fbshipit-source-id: 7689819de4c15f22e427cf5af520566bcea17bbc --- Libraries/Lists/VirtualizedSectionList.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Libraries/Lists/VirtualizedSectionList.js b/Libraries/Lists/VirtualizedSectionList.js index 594165ba02c..29bd5fdda39 100644 --- a/Libraries/Lists/VirtualizedSectionList.js +++ b/Libraries/Lists/VirtualizedSectionList.js @@ -341,8 +341,9 @@ class VirtualizedSectionList< viewableItems: Array, changed: Array, }) => { - if (this.props.onViewableItemsChanged) { - this.props.onViewableItemsChanged({ + const onViewableItemsChanged = this.props.onViewableItemsChanged; + if (onViewableItemsChanged != null) { + onViewableItemsChanged({ viewableItems: viewableItems .map(this._convertViewable, this) .filter(Boolean),