Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax FlatList.onViewableItemsChanged validation #39153

Closed
wants to merge 1 commit into from

Conversation

josephsavona
Copy link
Contributor

@josephsavona josephsavona commented Aug 24, 2023

Summary:
FlatList's restriction on not changing the onViewableItemsChanged prop forces developers to violate the rules of React, risking bugs and blocking the rollout of other improvements such as React Forget.

This diff relaxes the validation specifically for the seemingly common case in which a developer passes just a onViewableItemsChanged prop instead of viewabilityConfigCallbackPairs. We use an anonymous closure to create a stable identity that will be passed down to the underlying VirtualizedList, where the closure calls the current props.onViewableItemsChanged. The intent of this diff is to alleviate the worst impacts of the current restriction with a correct if not ideal solution, giving us time to fix the API more holistically.

Feedback welcome!

Changelog:

[Changed] - Allow passing different values to FlatList.onViewableItemsChanged

Differential Revision: D48656586

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Aug 24, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D48656586

Summary:
Pull Request resolved: facebook#39153

`FlatList`'s restriction on not changing the `onViewableItemsChanged` prop forces developers to violate the rules of React, risking bugs and blocking the rollout of other improvements such as React Forget.

This diff relaxes the validation specifically for the seemingly common case in which a developer passes just a onViewableItemsChanged prop instead of viewabilityConfigCallbackPairs. We use an anonymous closure to create a stable identity that will be passed down to the underlying VirtualizedList, where the closure calls the current `props.onViewableItemsChanged`. The intent of this diff is to alleviate the worst impacts of the current restriction with a correct if not ideal solution, giving us time to fix the API more holistically.

Feedback welcome!

## Changelog:
[Changed] - Allow passing different values to `FlatList.onViewableItemsChanged`

## Facebook

See https://fburl.com/workplace/9svfrytw for more context.

Reviewed By: NickGerleman

Differential Revision: D48656586

fbshipit-source-id: 005f946c9ebd3dd5875770f55de8634637444791
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D48656586

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 5cfa125.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants