Skip to content

Commit 5306e92

Browse files
aravi365meta-codesync[bot]
authored andcommitted
Add missing ListItemComponent prop to VirtualizedList/FlatList/SectionList TypeScript types (#57754)
Summary: `ListItemComponent` is a valid prop on `FlatList`, `SectionList` and `VirtualizedList` (it's in the Flow types in `VirtualizedListProps.js`), but it's missing from the `.d.ts`, so TypeScript errors on it even though it works at runtime. Added it to `VirtualizedListWithoutRenderItemProps` next to the other `List*Component` props, so all three inherit it. ## Changelog: [GENERAL] [ADDED] - Add missing ListItemComponent type to VirtualizedList props Pull Request resolved: #57754 Test Plan: Errors on `main`, type-checks with the change: ```tsx <FlatList data={[]} ListItemComponent={MyItem} /> ``` Type-only, addition only, no runtime changes. Reviewed By: Abbondanzo Differential Revision: D114061127 Pulled By: fabriziocucci fbshipit-source-id: e843645a93b2320370829e8fd86deda078d6852a
1 parent 8e74464 commit 5306e92

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

packages/virtualized-lists/Lists/VirtualizedList.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@ export interface VirtualizedListWithoutRenderItemProps<
188188
*/
189189
ListHeaderComponentStyle?: StyleProp<ViewStyle> | undefined;
190190

191+
/**
192+
* Each data item is rendered using this element, as an alternative to `renderItem`.
193+
* Can be a React Component Class or a render function. In addition to the data provided
194+
* to `renderItem`, this receives `index` and `separators` metadata.
195+
*/
196+
ListItemComponent?:
197+
React.ComponentType<any> | React.ReactElement | null | undefined;
198+
191199
/**
192200
* The default accessor functions assume this is an Array<{key: string}> but you can override
193201
* getItem, getItemCount, and keyExtractor to handle any type of index-based data.

0 commit comments

Comments
 (0)