3

I'm using react-native-tab-view in my App in which I have 2 tabs. I am loading Tab data via API call for creating infinite scroll pagination in side Tab, when data is concatenating in my FlatList data from API then each time my scroll bar reset to top position. I currently have snack demo like so: https://snack.expo.io/@luckyamit/9905d4

I don't want to reset my scroll bar on top in each API call i have search a lot for this issue but not find my solution. can any one help me to resolve my problem ?

luckyamit
  • 719
  • 2
  • 7
  • 19

2 Answers2

1

Did you solve it? For the others, this problem would be caused by this.

If you use SceneMap in renderScene property, you should not pass inline function. It triggers re-rendering so that the scroll position goes to top again.

Try to make them components instead of inline functions. Just do not use SceneMap is also an option.

jwKIM
  • 11
  • 2
1

i was able to fix by replace the renderscene inline by putting the logic inside only.

yes this is a prob

i replaced to the following code

 renderScene={({ route }) => {
    switch (route.key) {
      case 'feed':
        return FirstRoute();
        case 'groups':
       return SecondRoute();
     }
   }}

and i was able to fix the scroll to top issue

Apoorv
  • 1,338
  • 1
  • 17
  • 18