From 0b1561a467fadca3d59cc8a5c0052a75f38eb2fa Mon Sep 17 00:00:00 2001 From: Aravind M Nair Date: Wed, 16 Sep 2026 07:33:19 -0700 Subject: [PATCH] Fix misleading ListItemComponent JSDoc in VirtualizedList types (#58500) Summary: I added `ListItemComponent` to these types in https://github.com/react/react-native/issues/57754 and got the comment wrong. It says the component receives `index` and `separators` "in addition to the data provided to `renderItem`", which reads as if `renderItem` doesn't get them. It does. `_renderElement` in `VirtualizedListCellRenderer.js` passes the same `item`, `index` and `separators` to both. This fixes that sentence and mentions the one thing that actually is different, which is precedence. When both are set, `ListItemComponent` wins and `_renderElement` logs a warning saying so. ## Changelog: [INTERNAL] [FIXED] - Fix JSDoc for ListItemComponent in VirtualizedList types Pull Request resolved: https://github.com/react/react-native/pull/58500 Test Plan: Comment-only change in a `.d.ts`, no type changes. Checked the wording against `_renderElement`: ```js if (ListItemComponent) { return ( ); } if (renderItem) { return renderItem({item, index, separators: this._separators}); } ``` Reviewed By: cortinico Differential Revision: D120077066 Pulled By: Abbondanzo fbshipit-source-id: 489321ae950b169c9a985d18220d1ec84114e5fc --- packages/virtualized-lists/Lists/VirtualizedList.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/virtualized-lists/Lists/VirtualizedList.d.ts b/packages/virtualized-lists/Lists/VirtualizedList.d.ts index 85c1c9f258f..06d5e63b997 100644 --- a/packages/virtualized-lists/Lists/VirtualizedList.d.ts +++ b/packages/virtualized-lists/Lists/VirtualizedList.d.ts @@ -190,8 +190,8 @@ export interface VirtualizedListWithoutRenderItemProps< /** * Each data item is rendered using this element, as an alternative to `renderItem`. - * Can be a React Component Class or a render function. In addition to the data provided - * to `renderItem`, this receives `index` and `separators` metadata. + * It receives the same `item`, `index` and `separators` that `renderItem` gets. If both + * are provided, `ListItemComponent` takes precedence and a warning is logged. */ ListItemComponent?: React.ComponentType | React.ReactElement | null | undefined;