From aa28f4cd15bf4558ae9b5a913e4dd274497736f1 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Tue, 24 Jul 2018 10:59:14 +0200 Subject: [PATCH] Add section in SectionListRenderItemInfo --- types/react-native/index.d.ts | 14 ++++++++++++-- types/react-native/test/index.tsx | 5 +++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 2d3337c96d..9964c0c8ec 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -3973,7 +3973,7 @@ export interface SectionBase { key?: string; - renderItem?: ListRenderItem; + renderItem?: SectionListRenderItem; ItemSeparatorComponent?: React.ComponentClass | (() => React.ReactElement) | null; @@ -3984,6 +3984,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. @@ -4087,7 +4097,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 818be960c7..cb8807e13c 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -49,6 +49,7 @@ import { findNodeHandle, ScrollView, ScrollViewProps, + SectionListRenderItemInfo, RefreshControl, TabBarIOS, NativeModules, @@ -350,9 +351,9 @@ export class SectionListTest extends React.Component, { {section.title} )} - renderItem={(info: { item: string }) => ( + renderItem={(info: SectionListRenderItemInfo) => ( - {info.item} + {`${info.section.title} - ${info.item}`} )} />