react-native-pager-view icon indicating copy to clipboard operation
react-native-pager-view copied to clipboard

persist current page if we add item at the start of array

Open numandev1 opened this issue 4 years ago • 1 comments

Describe the feature

<PagerView
      ref={viewPagerRef}
      overdrag
      offscreenPageLimit={2}
      style={styles.sceneContainer}
      initialPage={offsetCurrentIndex.current}
      onPageSelected={onPageSelected}>
      {posts.items.map(renderItem)}
</PagerView>

for example, I have an array like this posts=[4,5,6,7] which I render in PagerView and go to the index 2 means 6 then I add some items at the start of the array

[1,2,3].concat(posts)

when I set state I lost my current page which is logical 6. I think there should be a prop for persisting current page if I add items at the start of an array

Motivation

like TIKTOK app, when we swipe up and up then pagination api call and TikTok add more video at the start of an array

Related Issues

N/A

numandev1 avatar Aug 16 '21 07:08 numandev1

Do you have a solution now?

verger-guo avatar Oct 24 '22 16:10 verger-guo