Add correct type for SectionList

This commit is contained in:
Tim Wang
2017-07-27 21:33:10 +08:00
parent 03b37e3f1b
commit cde9060ae1
2 changed files with 11 additions and 8 deletions

View File

@@ -3453,8 +3453,11 @@ export interface ViewabilityConfig {
*/
interface ListRenderItemInfo<ItemT> {
item: ItemT,
index: number,
item: ItemT
index: number
separators: {
highlight: () => void,
unhighlight: () => void,
@@ -3656,6 +3659,9 @@ export interface FlatListStatic<ItemT> extends React.ComponentClass<FlatListProp
recordInteraction: () => void
}
/**
* @see https://facebook.github.io/react-native/docs/sectionlist.html
*/
export interface SectionListData<ItemT> {
data: ItemT[]
@@ -3664,12 +3670,11 @@ export interface SectionListData<ItemT> {
renderItem?: ListRenderItem<ItemT>
ItemSeparatorComponent?: React.ComponentClass<any> | null
keyExtractor?: (item: ItemT, index: number) => string
}
/**
* @see https://facebook.github.io/react-native/docs/sectionlist.html
*/
export interface SectionListProperties<ItemT> extends ScrollViewProperties {
/**

View File

@@ -221,12 +221,10 @@ export class FlatListTest extends React.Component<FlatListProperties<number>, {}
export class SectionListTest extends React.Component<SectionListProperties<string>, {}> {
render() {
var sections = [{
title: 's1',
data: ['A', 'B', 'C', 'D', 'E']
}, {
title: 's2',
data: ['A2', 'B2', 'C2', 'D2', 'E2'],
renderItem: ({ item }) => <View><Text>{item}</Text></View>
renderItem: (info: { item: string }) => <View><Text>{info.item}</Text></View>
}];
return (