Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Making sense of maintainVisibleContentPosition - when loading data to start #1780

Answered by naqvitalha
ethanshar asked this question in Q&A
Discussion options

Hello 👋

I'm using FlashList to create an infinite, bi-directional list where data can be added to both the start and end of the list.

I noticed the new maintainVisibleContentPosition API and hoped it would help with my use case, but it’s not working as I expected. My goal is to keep the currently visible item in view (not just the scroll position) when adding content to the beginning of the list.

Right now, when I add new data to the start, the list jumps to the very first item instead of keeping me on the item I was viewing before the update.

From what I can tell, the API preserves the scroll offset at the moment new data is added, but since the list’s content shifts, the offset now points to a different item. I think if the scroll position could be adjusted by the height of the new content added at the top, it would maintain the correct visible item.

Is there a recommended way to achieve this behavior?

You must be logged in to vote

Do you have a valid keyExtractor? Also, make sure you're using v2 on new arch.

Replies: 1 comment 1 reply

Comment options

Do you have a valid keyExtractor? Also, make sure you're using v2 on new arch.

You must be logged in to vote
1 reply
Comment options

It's supposed to work like you mentioned.

Answer selected by ethanshar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /