Merge pull request #27522 from VincentLanglet/patch-2

[React native] Add section in SectionListRenderItemInfo
This commit is contained in:
Eloy Durán
2018-08-13 15:12:04 +02:00
committed by GitHub
2 changed files with 15 additions and 4 deletions

View File

@@ -4028,7 +4028,7 @@ export interface SectionBase<ItemT> {
key?: string;
renderItem?: ListRenderItem<ItemT>;
renderItem?: SectionListRenderItem<ItemT>;
ItemSeparatorComponent?: React.ComponentClass<any> | (() => React.ReactElement<any>) | null;
@@ -4039,6 +4039,16 @@ export interface SectionListData<ItemT> extends SectionBase<ItemT> {
[key: string]: any;
}
/**
* @see https://facebook.github.io/react-native/docs/sectionlist.html#props
*/
export interface SectionListRenderItemInfo<ItemT> extends ListRenderItemInfo<ItemT> {
section: SectionListData<ItemT>;
}
export type SectionListRenderItem<ItemT> = (info: SectionListRenderItemInfo<ItemT>) => React.ReactElement<any> | null;
export interface SectionListProps<ItemT> extends ScrollViewProps {
/**
* Rendered in between adjacent Items within each section.
@@ -4142,7 +4152,7 @@ export interface SectionListProps<ItemT> extends ScrollViewProps {
/**
* Default renderer for every item in every section. Can be over-ridden on a per-section basis.
*/
renderItem?: ListRenderItem<ItemT>;
renderItem?: SectionListRenderItem<ItemT>;
/**
* Rendered at the top of each section. Sticky headers are not yet supported.

View File

@@ -50,6 +50,7 @@ import {
findNodeHandle,
ScrollView,
ScrollViewProps,
SectionListRenderItemInfo,
RefreshControl,
TabBarIOS,
NativeModules,
@@ -352,9 +353,9 @@ export class SectionListTest extends React.Component<SectionListProps<string>, {
<Text>{section.title}</Text>
</View>
)}
renderItem={(info: { item: string }) => (
renderItem={(info: SectionListRenderItemInfo<string>) => (
<View>
<Text>{info.item}</Text>
<Text>{`${info.section.title} - ${info.item}`}</Text>
</View>
)}
/>