react-native-sideswipe: Setting the index of the item to be displayed does not work

Hey @kkemple

Thanks for the great and simple library. I managed to get working for one of my project without any problem (once I had read #23 that is 😃)

I found an issue when setting the index of the item to be rendered first. It really only works when setting the value is equal to 0.

I have created a snack to reproduce the issue. Basically I am displaying a bunch of text in a view

const data = [
  { text: 'THIS IS TEXT 0' },
  { text: 'THIS IS TEXT 1' },
  { text: 'THIS IS TEXT 2' },
  { text: 'THIS IS TEXT 3' },
  { text: 'THIS IS TEXT 4' }
];

and setting the item to be displayed first to entry 3

<SideSwipe
          index={3}
...

What’s happening is that THIS IS TEXT 0 shows up on screen first. As soon as I start swiping, even by the slightest swipe movement, the text updates to THIS IS TEXT 3 as expected.

To reproduce:

  • Load snack
  • Start swiping

Observe text changing from THIS IS TEXT 0 to THIS IS TEXT 3

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

I fixed this… A little confused over the other branch…

Just put:

initialScrollIndex={currentIndex}

anywhere in the <AnimatedFlatList (line 127 is where I put it.

Works perfectly…

Much simpler than flatlist… Thanks… Have same issue with the starting index though… Thanks Kurtis!

@kkemple Awesome. Happy to try it out on my app as well and report if I see any regressions. Cheers