Skip to content

Fix onStartReached not called#46250

Closed
janicduplessis wants to merge 1 commit intofacebook:mainfrom
janicduplessis:@janic/vl-fix
Closed

Fix onStartReached not called#46250
janicduplessis wants to merge 1 commit intofacebook:mainfrom
janicduplessis:@janic/vl-fix

Conversation

@janicduplessis
Copy link
Copy Markdown
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
@cipolleschi cipolleschi closed this Nov 5, 2024
@cipolleschi cipolleschi reopened this Nov 5, 2024
@cipolleschi cipolleschi closed this Nov 5, 2024
@cipolleschi cipolleschi reopened this Nov 5, 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.

3 participants