mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 20:39:17 +08:00
Add correct type for SectionList
This commit is contained in:
15
types/react-native/index.d.ts
vendored
15
types/react-native/index.d.ts
vendored
@@ -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 {
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user