react-nativereact-native-swiper

How do I know which page I am on(react-native-swiper)?


I am developing a small app with React Native and I am using "react-native-swiper" in my app. In this package "react-native-swiper", how do I know which page I am on now? Can I get some value indicates which slide I am on such as slide index? Now in the screen, there are 2 slides and every slides have same image which position is eccentric outside the slide. And I overlapped 2 images.

The problem is that:

In android, while I push from slide 1 to slide 2, then pink image disappear, but not iOS. So I want to control it's opacity according to the slide index.

How to get the slide index in "react-native-swiper"?

image


Solution

  • you can use onIndexChanged prop function Called with the new index when the user swiped This will give you the index of the current slide.