From e250e162ef25e389ef5c918fa85c64e7b8caf23d Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Wed, 26 Jul 2017 15:21:56 +0800 Subject: [PATCH] Fix renderItem() types in FlatListProperties ref: http://facebook.github.io/react-native/docs/flatlist.html --- types/react-native/index.d.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 42fe51fc8c..393e0dff62 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -4,6 +4,7 @@ // Fedor Nezhivoi // HuHuanming // Kyle Roach +// Tim Wang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -3421,7 +3422,7 @@ export interface ViewToken { export interface ViewabilityConfig { /** * Minimum amount of time (in milliseconds) that an item must be physically viewable before the - * viewability callback will be fired. A high number means that scrolling through content without + * viewability callback will be fired. A high number means that Fscrolling through content without * stopping will not mark the content as viewable. */ minimumViewTime?: number; @@ -3450,6 +3451,17 @@ export interface ViewabilityConfig { /** * @see https://facebook.github.io/react-native/docs/flatlist.html#props */ + +interface FlatListRenderItemInfo { + item: ItemT, + index: number, + separators: { + highlight: () => void, + unhighlight: () => void, + updateProps: (select: 'leading' | 'trailing', newProps: any) => void, + }, +} + export interface FlatListProperties extends ScrollViewProperties { /** @@ -3584,7 +3596,7 @@ export interface FlatListProperties extends ScrollViewProperties { * ``` * Provides additional metadata like `index` if you need it. */ - renderItem: (info: ItemT) => React.ReactElement | null + renderItem: (info: FlatListRenderItemInfo) => React.ReactElement | null /** * See `ViewabilityHelper` for flow type and further documentation.