mirror of
https://github.com/react/react-native.git
synced 2026-09-28 13:23:09 +08:00
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 ( <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
This commit is contained in:
committed by
meta-codesync[bot]
parent
7fc66ccda5
commit
0b1561a467
+2
-2
@@ -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<any> | React.ReactElement | null | undefined;
|
||||
|
||||
Reference in New Issue
Block a user