Skip to content

Commit 0b1561a

Browse files
aravi365meta-codesync[bot]
authored andcommitted
Fix misleading ListItemComponent JSDoc in VirtualizedList types (#58500)
Summary: I added `ListItemComponent` to these types in #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: #58500 Test Plan: Comment-only change in a `.d.ts`, no type changes. Checked the wording against `_renderElement`: ```js if (ListItemComponent) { return ( <ListItemComponent item={item} index={index} separators={this._separators} /> ); } if (renderItem) { return renderItem({item, index, separators: this._separators}); } ``` Reviewed By: cortinico Differential Revision: D120077066 Pulled By: Abbondanzo fbshipit-source-id: 489321ae950b169c9a985d18220d1ec84114e5fc
1 parent 7fc66cc commit 0b1561a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ export interface VirtualizedListWithoutRenderItemProps<
190190

191191
/**
192192
* 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.
193+
* It receives the same `item`, `index` and `separators` that `renderItem` gets. If both
194+
* are provided, `ListItemComponent` takes precedence and a warning is logged.
195195
*/
196196
ListItemComponent?:
197197
React.ComponentType<any> | React.ReactElement | null | undefined;

0 commit comments

Comments
 (0)