-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
onEndReached first mount Render fix #46350
base: main
Are you sure you want to change the base?
Conversation
onEndReached first mount Render fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks good to me. Importing it to have more eyes on it.
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@@ -1542,7 +1542,10 @@ class VirtualizedList extends StateSafePureComponent<Props, State> { | |||
this._listMetrics.getContentLength() !== this._sentEndForContentLength | |||
) { | |||
this._sentEndForContentLength = this._listMetrics.getContentLength(); | |||
onEndReached({distanceFromEnd}); | |||
// It will only runs when data is available and also it wont trigger onEndReached on First Mount as data will be empty | |||
if (data && data.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a colleague of mine:
It wont trigger onEndReached on First Mount as data will be empty
This is not true, apart from maybe in this users specific scenario.
It also is inconsistent with the logic below for onStartReached
.
And... we can render e.g. headers
From this comment, I believe we can't really land the change (also a test is failing internally, I'm trying to figure out if that's because of this change).
In the body of the PR, you mention:
... will also prevent onEndReached calls on first mount thus prevent the bug for OnEndReached.
Is there an issue for the "bug for OnEndReached"? do you mind linking it here so we can match the issue with the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cipolleschi ,
In my PR, there are fixes related to two bugs. I encountered an issue where FlatList calls onEndReached twice, even when the data is empty. To address this, I added a check to ensure that onEndReached is only called when there is data, otherwise there is no reason for onEndReached to be triggered.
Additionally, onStartReached is functioning separately and independently. Could you please clarify how it is related to this?
Can you please also elaborate me about the test which has been failed ?
Thank you.
https://github.com/facebook/react-native/issues/45771
https://github.com/facebook/react-native/issues/38090
@cipolleschi hi, this is one (open) |
Fix OnEndReached Call Twice on First Mount it will only call onEndReached when there is data available
refactor logic
/rebase - this comment automatically rebase on top of main |
[iOS] [ANDROID] [Fixed] - onEndReached Calls on First Mount Fix
onEndReached first mount Render fix
onEndReached will only calls when data is available as there is no need to call onEndReached to call when data is not present which will also prevent onEndReached calls on first mount thus prevent the bug for OnEndReached.
Summary:
Changelog:
[iOS] [ANDROID] [Changed] - onEndReached Calls on First Mount Fix
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
Test Plan: