Skip to content

Commit

Permalink
Loosen SectionList renderItem required return type (#45305)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #45305

Allow SectionList render functions to return any React node, instead of just React.Element. This matches VirtualizedList/FlatList, and general Flow component conventions.

Changelog:
[General][Fixed] - Loosen SectionList `renderItem` required return type

Reviewed By: joevilches

Differential Revision: D59404511

fbshipit-source-id: 3055d8f01845ff5ef8ae75b87f60d8cd26dc07b4
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Jul 9, 2024
1 parent 3441641 commit 12b64b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/react-native/Libraries/Lists/SectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type OptionalProps<SectionT: SectionBase<any>> = {|
...
},
...
}) => null | React.Element<any>,
}) => null | React.Node,
/**
* A marker property for telling the list to re-render (since it implements `PureComponent`). If
* any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the
Expand Down
12 changes: 3 additions & 9 deletions packages/virtualized-lists/Lists/VirtualizedSectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,16 @@ type OptionalProps<SectionT: SectionBase<any>> = {|
...
},
...
}) => null | React.Element<any>,
}) => null | React.Node,
/**
* 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,
...
}) => null | React.Element<any>,
renderSectionHeader?: ?(info: {section: SectionT, ...}) => null | React.Node,
/**
* Rendered at the bottom of each section.
*/
renderSectionFooter?: ?(info: {
section: SectionT,
...
}) => null | React.Element<any>,
renderSectionFooter?: ?(info: {section: SectionT, ...}) => null | React.Node,
/**
* Rendered at the top and bottom of each section (note this is different from
* `ItemSeparatorComponent` which is only rendered between items). These are intended to separate
Expand Down

0 comments on commit 12b64b7

Please sign in to comment.