meliorence / react-native-snap-carousel

Swiper/carousel component for React Native featuring previews, multiple layouts, parallax images, performant handling of huge numbers of items, and more. Compatible with Android & iOS.
BSD 3-Clause "New" or "Revised" License
10.34k stars 2.28k forks source link

snapToNext() and snapToPrev() are not working when using snapToItem() #434

Open MoKhajavi75 opened 5 years ago

MoKhajavi75 commented 5 years ago

Is this a bug report, a feature request, or a question?

Bug report

Have you followed the required steps before opening a bug report?

Have you made sure that it wasn't a React Native bug?

Yes

Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?

I'm on the Android 7

Is the bug reproductible in a production environment (not a debug one)?

Yes - I tried the released apk but i got the bug!

Environment

Environment:
    React: 16.6.1
    React native: 0.57.5
    react-native-snap-carousel: ^3.7.5

  Target Platform:
    Android (7.0)

Expected Behavior

snapToNext() and snapToPrev() should work properly.

Actual Behavior

snapToNext() and snapToPrev() are not working!

Reproducible Demo

I'm using AsyncStorage.setItem() to save the this.carousel.currentIndex in componentWillUnmount() and then i use AsyncStorage.getItem() to get the index and this.carousel.snapToItem(responseIndex) in the componentWillMount(). This is working BUT when i use this.carousel.snapToItem(responseIndex) , the snapToNext() and snapToPrev() are not working!

Steps to Reproduce

  1. react-native init TestingProject
  2. yarn add react-native-snap-carousel
  3. use AsyncStorage and what i mentioned in the Reproducible Demo
bd-arc commented 5 years ago

Hi @MohamadKh75,

Can you please provide a Snack example in which the issue can be reproduced?

MoKhajavi75 commented 5 years ago

Hi @MohamadKh75,

Can you please provide a Snack example in which the issue can be reproduced?

I'll do that asap, for now, i just use this.carousel.snapToItem(index + 1) and this.carousel.snapToItem(index - 1) :grin:

Romick2005 commented 4 years ago

Can you please check if #522 fixed this for you?

dohooo commented 2 years ago

Sorry, please allow me to advertise for my open source library! ~ I think this library react-native-reanimated-carousel will solve your problem. It is a high performance and very simple component, complete with React-Native reanimated 2