Lists: Change flow type to not allow rendering undefined

Summary:
`?React.Element<any>` allows passing in `undefined`, an invalid value to render into a React component. Changing these types to be `null | React.Element<any>`.

The issues that this caught were fixed in a previous diff.

Reviewed By: lunaleaps

Differential Revision: D17859220

fbshipit-source-id: 71438cb357b44bca0bf3437aea99ece99a616f7d
This commit is contained in:
Eli White
2019-10-11 09:49:28 -07:00
committed by Facebook Github Bot
parent 51bf5f9962
commit 55b32130bb
2 changed files with 11 additions and 7 deletions
+7 -3
View File
@@ -53,7 +53,7 @@ type OptionalProps<SectionT: SectionBase<any>> = {
unhighlight: () => void,
updateProps: (select: 'leading' | 'trailing', newProps: Object) => void,
},
}) => ?React.Element<any>,
}) => null | React.Element<any>,
/**
* Rendered in between each item, but not at the top or bottom. By default, `highlighted`,
* `section`, and `[leading/trailing][Item/Separator]` props are provided. `renderItem` provides
@@ -146,11 +146,15 @@ type OptionalProps<SectionT: SectionBase<any>> = {
* Rendered at the top of each section. These stick to the top of the `ScrollView` by default on
* iOS. See `stickySectionHeadersEnabled`.
*/
renderSectionHeader?: ?(info: {section: SectionT}) => ?React.Element<any>,
renderSectionHeader?: ?(info: {
section: SectionT,
}) => null | React.Element<any>,
/**
* Rendered at the bottom of each section.
*/
renderSectionFooter?: ?(info: {section: SectionT}) => ?React.Element<any>,
renderSectionFooter?: ?(info: {
section: SectionT,
}) => null | React.Element<any>,
/**
* Makes section headers stick to the top of the screen until the next one pushes it off. Only
* enabled by default on iOS because that is the platform standard there.
+4 -4
View File
@@ -41,7 +41,7 @@ export type SectionBase<SectionItemT> = {
unhighlight: () => void,
updateProps: (select: 'leading' | 'trailing', newProps: Object) => void,
},
}) => ?React.Element<any>,
}) => null | React.Element<any>,
ItemSeparatorComponent?: ?React.ComponentType<any>,
keyExtractor?: (item: SectionItemT, index?: ?number) => string,
};
@@ -71,15 +71,15 @@ type OptionalProps<SectionT: SectionBase<any>> = {
unhighlight: () => void,
updateProps: (select: 'leading' | 'trailing', newProps: Object) => void,
},
}) => ?React.Element<any>,
}) => null | React.Element<any>,
/**
* Rendered at the top of each section.
*/
renderSectionHeader?: ?({section: SectionT}) => ?React.Element<any>,
renderSectionHeader?: ?({section: SectionT}) => null | React.Element<any>,
/**
* Rendered at the bottom of each section.
*/
renderSectionFooter?: ?({section: SectionT}) => ?React.Element<any>,
renderSectionFooter?: ?({section: SectionT}) => null | React.Element<any>,
/**
* Rendered at the bottom of every Section, except the very last one, in place of the normal
* ItemSeparatorComponent.