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

Fix onStartReached not called #46250

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

janicduplessis
Copy link
Contributor

Summary:

I've seen some cases where onStartReached calls would be missed. This seems to happen because we bail out of calling onStartReached if our current viewport is not currently at index 0 (

this.state.cellsAroundViewport.first === 0 &&
). However if no further scroll event happens after finally adjusting the viewport to render 0 we never end up calling onStartReached. To fix this we can try calling _maybeCallOnEdgeReached whenever the viewport changes.

I also seen cases where firstVisibleItemKey would be incorrect because of the early return here. To be honest I am not exactly sure why, but prevState.renderMask.numCells() doesn't actually have the item count from the previous render, but the current item could, which would cause that code to return incorrectly and not update firstVisibleItemKey. To fix this I am also tracking lastItemCount in the state and comparing this too instead of relying only on prevState.renderMask.numCells().

Changelog:

[GENERAL] [FIXED] - Fix onStartReached not called in some cases

Test Plan:

Tested in the Expensify app to test that this fixes some cases we saw of onStartReached not being called.

@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. Contributor A React Native contributor. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Aug 28, 2024
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. Contributor A React Native contributor. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants