@@ -52,7 +52,7 @@ type RequiredProps = {
52
52
// `VirtualizedSectionList`'s props.
53
53
renderItem : $FlowFixMe < renderItemType > ,
54
54
/**
55
- * The default accessor functions assume this is an Array<{key: string}> but you can override
55
+ * The default accessor functions assume this is an Array<{key: string} | {id: string} > but you can override
56
56
* getItem, getItemCount, and keyExtractor to handle any type of index-based data.
57
57
*/
58
58
data ?: any ,
@@ -264,7 +264,7 @@ type State = {first: number, last: number};
264
264
* offscreen. This means it's possible to scroll faster than the fill rate ands momentarily see
265
265
* blank content. This is a tradeoff that can be adjusted to suit the needs of each application,
266
266
* and we are working on improving it behind the scenes.
267
- * - By default, the list looks for a `key` prop on each item and uses that for the React key.
267
+ * - By default, the list looks for a `key` or `id` prop on each item and uses that for the React key.
268
268
* Alternatively, you can provide a custom `keyExtractor` prop.
269
269
*
270
270
*/
@@ -435,6 +435,9 @@ class VirtualizedList extends React.PureComponent<Props, State> {
435
435
if ( item . key != null ) {
436
436
return item . key ;
437
437
}
438
+ if ( item . id != null ) {
439
+ return item . id ;
440
+ }
438
441
_usedIndexForKey = true ;
439
442
if ( item . type && item . type . displayName ) {
440
443
_keylessItemComponentName = item . type . displayName ;
@@ -849,7 +852,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
849
852
) ;
850
853
if ( ! this . _hasWarned . keys && _usedIndexForKey ) {
851
854
console . warn (
852
- 'VirtualizedList: missing keys for items, make sure to specify a key property on each ' +
855
+ 'VirtualizedList: missing keys for items, make sure to specify a key or id property on each ' +
853
856
'item or provide a custom keyExtractor.' ,
854
857
_keylessItemComponentName ,
855
858
) ;
0 commit comments