Skip to content

Commit

Permalink
VirtualizedList onViewableItemsChanged won't trigger if first item in…
Browse files Browse the repository at this point in the history
… data evaluate to false #35280 (#35282)

Summary:
VirtualizedList onViewableItemsChanged won't trigger if first item in data evaluate to false #35280

Described in #35280

## Changelog

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

Pull Request resolved: #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
  • Loading branch information
samchan0221 authored and facebook-github-bot committed Nov 9, 2022
1 parent 1ad083a commit 1f0c2c2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Libraries/Lists/VirtualizedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1f0c2c2

Please sign in to comment.