24ark / react-native-step-indicator

A simple react-native implementation of step indicator widget compatible with the ViewPager and ListView.
Apache License 2.0
1.42k stars 312 forks source link

Not swiping when changing Page Index on Android #116

Closed Mgxcx closed 3 years ago

Mgxcx commented 3 years ago

Hi !

I used the Horizontal Step Indicator Example. And I added a little functionality : I passed nextPage props to my step screens, and I called this props on a button click in each step screen in order to change the currentPage state index and swipe to the next page: Capture d’écran 2021-04-30 à 18 21 40

It works well on iOS but not on Android, and I don't understand where the issue is...

You can see my code below : Capture d’écran 2021-04-30 à 18 21 20 Capture d’écran 2021-04-30 à 18 20 55

Thanks for your help 🙏

hayder-grability commented 3 years ago

Some notice from this theme?

hayder-grability commented 3 years ago

Maybe this can help you

  1. create a ref const swiperRef = useRef<any>(null);

  2. Use the component without index <Swiper ref={swiperRef} loop={false} // index={step} autoplay={false} showsButtons={false} scrollEnabled={false} showsPagination={false} />

    1. Then use it when use onPress

swiperRef.current.scrollTo(position);

Mgxcx commented 3 years ago

It works ! Thanks a lot 🙏