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
This commit is contained in:
Eli White
2019-10-11 09:49:30 -07:00
committed by Facebook Github Bot
parent ce3628e9d8
commit bd70cbf042
+3 -2
View File
@@ -341,8 +341,9 @@ class VirtualizedSectionList<
viewableItems: Array<ViewToken>,
changed: Array<ViewToken>,
}) => {
if (this.props.onViewableItemsChanged) {
this.props.onViewableItemsChanged({
const onViewableItemsChanged = this.props.onViewableItemsChanged;
if (onViewableItemsChanged != null) {
onViewableItemsChanged({
viewableItems: viewableItems
.map(this._convertViewable, this)
.filter(Boolean),