diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 40d833c0f5..5a49af5685 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -4028,7 +4028,7 @@ export interface SectionBase { key?: string; - renderItem?: ListRenderItem; + renderItem?: SectionListRenderItem; ItemSeparatorComponent?: React.ComponentClass | (() => React.ReactElement) | null; @@ -4039,6 +4039,16 @@ export interface SectionListData extends SectionBase { [key: string]: any; } +/** + * @see https://facebook.github.io/react-native/docs/sectionlist.html#props + */ + +export interface SectionListRenderItemInfo extends ListRenderItemInfo { + section: SectionListData; +} + +export type SectionListRenderItem = (info: SectionListRenderItemInfo) => React.ReactElement | null; + export interface SectionListProps extends ScrollViewProps { /** * Rendered in between adjacent Items within each section. @@ -4142,7 +4152,7 @@ export interface SectionListProps extends ScrollViewProps { /** * Default renderer for every item in every section. Can be over-ridden on a per-section basis. */ - renderItem?: ListRenderItem; + renderItem?: SectionListRenderItem; /** * Rendered at the top of each section. Sticky headers are not yet supported. diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 2980ac9f62..0399d41321 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -50,6 +50,7 @@ import { findNodeHandle, ScrollView, ScrollViewProps, + SectionListRenderItemInfo, RefreshControl, TabBarIOS, NativeModules, @@ -352,9 +353,9 @@ export class SectionListTest extends React.Component, { {section.title} )} - renderItem={(info: { item: string }) => ( + renderItem={(info: SectionListRenderItemInfo) => ( - {info.item} + {`${info.section.title} - ${info.item}`} )} />