mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Merge pull request #27522 from VincentLanglet/patch-2
[React native] Add section in SectionListRenderItemInfo
This commit is contained in:
14
types/react-native/index.d.ts
vendored
14
types/react-native/index.d.ts
vendored
@@ -4028,7 +4028,7 @@ export interface SectionBase<ItemT> {
|
||||
|
||||
key?: string;
|
||||
|
||||
renderItem?: ListRenderItem<ItemT>;
|
||||
renderItem?: SectionListRenderItem<ItemT>;
|
||||
|
||||
ItemSeparatorComponent?: React.ComponentClass<any> | (() => React.ReactElement<any>) | null;
|
||||
|
||||
@@ -4039,6 +4039,16 @@ export interface SectionListData<ItemT> extends SectionBase<ItemT> {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://facebook.github.io/react-native/docs/sectionlist.html#props
|
||||
*/
|
||||
|
||||
export interface SectionListRenderItemInfo<ItemT> extends ListRenderItemInfo<ItemT> {
|
||||
section: SectionListData<ItemT>;
|
||||
}
|
||||
|
||||
export type SectionListRenderItem<ItemT> = (info: SectionListRenderItemInfo<ItemT>) => React.ReactElement<any> | null;
|
||||
|
||||
export interface SectionListProps<ItemT> extends ScrollViewProps {
|
||||
/**
|
||||
* Rendered in between adjacent Items within each section.
|
||||
@@ -4142,7 +4152,7 @@ export interface SectionListProps<ItemT> extends ScrollViewProps {
|
||||
/**
|
||||
* Default renderer for every item in every section. Can be over-ridden on a per-section basis.
|
||||
*/
|
||||
renderItem?: ListRenderItem<ItemT>;
|
||||
renderItem?: SectionListRenderItem<ItemT>;
|
||||
|
||||
/**
|
||||
* Rendered at the top of each section. Sticky headers are not yet supported.
|
||||
|
||||
@@ -50,6 +50,7 @@ import {
|
||||
findNodeHandle,
|
||||
ScrollView,
|
||||
ScrollViewProps,
|
||||
SectionListRenderItemInfo,
|
||||
RefreshControl,
|
||||
TabBarIOS,
|
||||
NativeModules,
|
||||
@@ -352,9 +353,9 @@ export class SectionListTest extends React.Component<SectionListProps<string>, {
|
||||
<Text>{section.title}</Text>
|
||||
</View>
|
||||
)}
|
||||
renderItem={(info: { item: string }) => (
|
||||
renderItem={(info: SectionListRenderItemInfo<string>) => (
|
||||
<View>
|
||||
<Text>{info.item}</Text>
|
||||
<Text>{`${info.section.title} - ${info.item}`}</Text>
|
||||
</View>
|
||||
)}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user