onViewableItemsChanged isn't correct without specifying the header height in getItemLayout #48351
Labels
Needs: Author Feedback
Type: Unsupported Version
Issues reported to a version of React Native that is no longer supported
Description
I am unsure if this is a bug or expected behaviour. If it's the latter then could be worth adding to the docs.
Also I can only test on my version (0.73.8) unfortunately. But I can't find any issues that suggest it's been fixed recently, so hopefully a useful issue for people. At the very least I couldn't find anything about this online so maybe useful for others.
If I have a simple Flatlist with a header like this:
If I remove the header height (200) from the getItemLayout offset calculation, onViewableItemsChanged fires incorrectly.
If I remove getItemLayout entirely, the logic works fine regardless.
I would have thought by the time the layout has rendered, the onViewableItemsChanged logic would be able to use the actual layout value vs relying on getItemLayout? It would certainly make things robust for us since the header height is quite dependent on various things.
Steps to reproduce
Run the code snippet above. Scroll down and observe that onViewableItemsChanged fires correctly. Remove 200 from getItemLayout calculation and observe it is now incorrect.
React Native Version
0.73.8
Affected Platforms
Runtime - Android, Runtime - iOS
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/matt-dalton/flatlistviewable
Screenshots and Videos
No response
The text was updated successfully, but these errors were encountered: