VirtualizedList onViewableItemsChanged won't trigger if first item in data evaluate to false #35280 (#35282)

Summary:
VirtualizedList onViewableItemsChanged won't trigger if first item in data evaluate to false https://github.com/facebook/react-native/issues/35280

Described in https://github.com/facebook/react-native/issues/35280

## Changelog

- [General] [Fixed] Fix VirtualizedList onViewableItemsChanged won't trigger if first item in data evaluate to false

Pull Request resolved: https://github.com/facebook/react-native/pull/35282

Test Plan:
this snack will be able to log `onViewableItemsChanged triggered` after the fix:
https://snack.expo.dev/tmQo_R_3Y

Reviewed By: jacdebug

Differential Revision: D41158485

Pulled By: NickGerleman

fbshipit-source-id: 47434890155abe009c2560b658adc4e067c31027
This commit is contained in:
Sam Chan 2022-11-09 11:35:45 -08:00 коммит произвёл Facebook GitHub Bot
Родитель 1ad083a138
Коммит 1f0c2c2895
1 изменённых файлов: 4 добавлений и 1 удалений

Просмотреть файл

@ -1749,7 +1749,10 @@ export default class VirtualizedList extends StateSafePureComponent<
'Tried to get frame for out of range index ' + index,
);
const item = getItem(data, index);
const frame = item && this._frames[this._keyExtractor(item, index, props)];
const frame =
item != null
? this._frames[this._keyExtractor(item, index, props)]
: undefined;
if (!frame || frame.index !== index) {
if (getItemLayout) {
/* $FlowFixMe[prop-missing] (>=0.63.0 site=react_native_fb) This comment