Skip to content

Commit

Permalink
Fix virtual list type (#35434)
Browse files Browse the repository at this point in the history
Summary:
Add missing props to virtual list

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[General] [Fixed] - Virtual list props

Pull Request resolved: #35434

Test Plan:
relative pull request in DefinitelyTyped
DefinitelyTyped/DefinitelyTyped#63323

Reviewed By: javache

Differential Revision: D41553396

Pulled By: NickGerleman

fbshipit-source-id: d51a93410ece9ad5f0bb61e2ee51076973e80c8c
  • Loading branch information
aliakbarazizi authored and facebook-github-bot committed Nov 28, 2022
1 parent 4e66816 commit 6c33fd1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 84 deletions.
42 changes: 0 additions & 42 deletions Libraries/Lists/FlatList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,6 @@ import {ViewStyle} from '../StyleSheet/StyleSheetTypes';
import {View} from '../Components/View/View';

export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {
/**
* Rendered in between each item, but not at the top or bottom
*/
ItemSeparatorComponent?: React.ComponentType<any> | null | undefined;

/**
* Rendered when the list is empty.
*/
ListEmptyComponent?:
| React.ComponentType<any>
| React.ReactElement
| null
| undefined;

/**
* Rendered at the very end of the list.
*/
ListFooterComponent?:
| React.ComponentType<any>
| React.ReactElement
| null
| undefined;

/**
* Styling for internal View for ListFooterComponent
*/
ListFooterComponentStyle?: StyleProp<ViewStyle> | undefined;

/**
* Rendered at the very beginning of the list.
*/
ListHeaderComponent?:
| React.ComponentType<any>
| React.ReactElement
| null
| undefined;

/**
* Styling for internal View for ListHeaderComponent
*/
ListHeaderComponentStyle?: StyleProp<ViewStyle> | undefined;

/**
* Optional custom style for multi-item rows generated when numColumns > 1
*/
Expand Down
42 changes: 0 additions & 42 deletions Libraries/Lists/SectionList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,48 +61,6 @@ export type SectionListRenderItem<ItemT, SectionT = DefaultSectionT> = (

export interface SectionListProps<ItemT, SectionT = DefaultSectionT>
extends VirtualizedListWithoutRenderItemProps<ItemT> {
/**
* Rendered in between adjacent Items within each section.
*/
ItemSeparatorComponent?: React.ComponentType<any> | null | undefined;

/**
* Rendered when the list is empty.
*/
ListEmptyComponent?:
| React.ComponentType<any>
| React.ReactElement
| null
| undefined;

/**
* Rendered at the very end of the list.
*/
ListFooterComponent?:
| React.ComponentType<any>
| React.ReactElement
| null
| undefined;

/**
* Styling for internal View for ListFooterComponent
*/
ListFooterComponentStyle?: StyleProp<ViewStyle> | undefined | null;

/**
* Rendered at the very beginning of the list.
*/
ListHeaderComponent?:
| React.ComponentType<any>
| React.ReactElement
| null
| undefined;

/**
* Styling for internal View for ListHeaderComponent
*/
ListHeaderComponentStyle?: StyleProp<ViewStyle> | undefined | null;

/**
* Rendered in between each section.
*/
Expand Down
17 changes: 17 additions & 0 deletions Libraries/Lists/VirtualizedList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import type * as React from 'react';
import type {LayoutChangeEvent} from '../../types';
import {StyleProp} from '../StyleSheet/StyleSheet';
import {ViewStyle} from '../StyleSheet/StyleSheetTypes';
import type {ScrollViewProps} from '../Components/ScrollView/ScrollView';

export interface ViewToken {
Expand Down Expand Up @@ -124,6 +126,11 @@ export interface VirtualizedListProps<ItemT>

export interface VirtualizedListWithoutRenderItemProps<ItemT>
extends ScrollViewProps {
/**
* Rendered in between each item, but not at the top or bottom
*/
ItemSeparatorComponent?: React.ComponentType<any> | null | undefined;

/**
* Rendered when the list is empty. Can be a React Component Class, a render function, or
* a rendered element.
Expand All @@ -144,6 +151,11 @@ export interface VirtualizedListWithoutRenderItemProps<ItemT>
| null
| undefined;

/**
* Styling for internal View for ListFooterComponent
*/
ListFooterComponentStyle?: StyleProp<ViewStyle> | undefined;

/**
* Rendered at the top of all the items. Can be a React Component Class, a render function, or
* a rendered element.
Expand All @@ -154,6 +166,11 @@ export interface VirtualizedListWithoutRenderItemProps<ItemT>
| null
| undefined;

/**
* Styling for internal View for ListHeaderComponent
*/
ListHeaderComponentStyle?: StyleProp<ViewStyle> | undefined;

/**
* The default accessor functions assume this is an Array<{key: string}> but you can override
* getItem, getItemCount, and keyExtractor to handle any type of index-based data.
Expand Down

0 comments on commit 6c33fd1

Please sign in to comment.