React Native Scoll View maintains scroll position when adding content to the top

Viewed 44

I am building an app in react native where content gets added to the top when user scroll to the top of the scroll view. The content is loaded and appended to the top which pushes the rest of the content down. I want to maintain the location of the scroll view that the user saw otherwise they stay scrolled all the way to the top.

I know there is a contentOffset on ScrollView but how can I get the size of the new content being added in react such that I can offset the scroll view position so that the same content is visible. Has anyone had a similar issue and how did they solve this in react native using scroll view. I guess this must be a common problem solved by any chat based style application which loads more content when user scrolls up.

0 Answers
Related