-
Notifications
You must be signed in to change notification settings - Fork 365
Making sense of maintainVisibleContentPosition - when loading data to start #1780
-
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?
Beta Was this translation helpful? Give feedback.
All reactions
Do you have a valid keyExtractor? Also, make sure you're using v2 on new arch.
Replies: 1 comment 1 reply
-
Do you have a valid keyExtractor? Also, make sure you're using v2 on new arch.
Beta Was this translation helpful? Give feedback.
All reactions
-
It's supposed to work like you mentioned.
Beta Was this translation helpful? Give feedback.