Skip to content

Use the latest onViewableItemsChanged in VirtualizedList - #60574

Draft
neeleshyadav253 wants to merge 1 commit into
react:mainfrom
neeleshyadav253:fix/viewable-items-changed-on-the-fly
Draft

neeleshyadav253 wants to merge 1 commit into
react:mainfrom
neeleshyadav253:fix/viewable-items-changed-on-the-fly

Conversation

@neeleshyadav253

Copy link
Copy Markdown

Summary:

VirtualizedList builds its viewability tuples once, in the constructor. As a result, a changed onViewableItemsChanged prop was never called, and a callback added after mount was ignored. This change syncs the callback on each update and creates the tuple when the callback first appears. Existing helpers are reused, so their viewable-index state is kept.

Fixes #30171

Changelog:

[GENERAL] [FIXED] - FlatList and SectionList now call the latest onViewableItemsChanged after the prop changes or is added after mount.

Test Plan:

  • Added two tests to packages/virtualized-lists/Lists/__tests__/VirtualizedList-test.js. Both failed before the change and pass after it.
  • yarn jest packages/virtualized-lists: 11 suites passed, 208 tests passed, 1 skipped, 69 snapshots passed.
  • yarn eslint packages/virtualized-lists/Lists/VirtualizedList.js packages/virtualized-lists/Lists/__tests__/VirtualizedList-test.js --max-warnings 0: exit 0.
  • yarn prettier --check on the two files: passed.
  • yarn flow-check: 0 errors.
  • Not run on a device or simulator. The change is JavaScript-only.
  • Not handled in this PR: changing viewabilityConfig after mount still uses the original helper config.

The viewability tuples were built once in the constructor, so a changed
onViewableItemsChanged was never called and a callback added after mount
was ignored. Sync the callback on each update and create the tuple when
the callback first appears. Helpers are reused so their viewable-index
state is kept.

Signed-off-by: Neelesh-fs-dev <neeleshy263@gmail.com>
@neeleshyadav253
neeleshyadav253 force-pushed the fix/viewable-items-changed-on-the-fly branch from f3d1b25 to 227db35 Compare December 5, 2026 04:25

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changing onViewableItemsChanged on the fly is not supported

2 participants