react-native-snap-carousel icon indicating copy to clipboard operation
react-native-snap-carousel copied to clipboard

Snaptoitem doesn't work with more than 10 elements?

Open bishnudev opened this issue 5 years ago • 15 comments

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

Question

There're 11 cards in my snap carousel. When i try snapToItem(i) where i < 10, it works perfectly fine but when i try snapToItem(10), it just moves to the 10th card. Isn't it supposed to move to the 11th card since i'm passing a index of 10. Is there any kind of limit over number of cards in the snapcarousel?

bishnudev avatar May 03 '19 11:05 bishnudev

Hello,

I had the same issue and I solved it by using the initialNumToRender prop ! By default, all the slides are not rendered for optimization so I guess that's why snapToItem was not able to find the slide :)

LimAlbert avatar May 05 '19 15:05 LimAlbert

It looks like the new version 3.8.0 has a bug, I only have 3 items but snaptoitem works only for the first call/action then its not functioning, same with snaptonext and snaptoprev. I;m using the latest RN0.59.8

@LimAlbert initialNumToRender didn't work for me

eggybot avatar Jun 02 '19 12:06 eggybot

@eggybot i have the same issue, do you have any solution?

cr1s3c avatar Jun 05 '19 14:06 cr1s3c

@cr1s3c I revert back to version 3.7.5, will wait till this issue resolve.

eggybot avatar Jun 05 '19 14:06 eggybot

@eggybot thank you, after reverting to 3.7.5 and reverting react from 16.8.3 to 16.6.3 it is working again.

cr1s3c avatar Jun 05 '19 14:06 cr1s3c

Well, I now need to find out which one of the PR I recently merged is responsible for that.

#443 is a strong candidate IMO. If someone has the time to test if reverting this fixes the issue, I'd really appreciate it.

bd-arc avatar Jun 06 '19 07:06 bd-arc

I have the same issue and going back to 3.7.5 did not solve the problem. React 16.8.3 and RN0.59.8.

@bd-arc I tested if reverting this on 3.8.0 solves the issue, but unfortunately seems not...

rafalzawadzki avatar Jun 07 '19 11:06 rafalzawadzki

@rafalzawadzki try uninstall/install it works for me.

eggybot avatar Jun 07 '19 12:06 eggybot

@eggybot Thanks 3.7.5 for fixing my problem

hanwenbo avatar Jul 29 '19 16:07 hanwenbo

Any update on this? I have a Carousel with almost 300 items, and it's simply impossible to set initialNumToRender that large with acceptable performance. :(

vittau avatar May 27 '20 21:05 vittau

@vittau Have you given a try to version 4.0.0-beta.4?

We're now relying on FlatList's initialScrollIndex, which should help with large datasets.

bd-arc avatar May 28 '20 05:05 bd-arc

@vittau Have you given a try to version 4.0.0-beta.4?

We're now relying on FlatList's initialScrollIndex, which should help with large datasets.

Thank you! It really does work correctly now without having to set initialNumToRender. :)

vittau avatar May 28 '20 21:05 vittau

Something interesting I meet when trying fix this problem. I have very loaded screen with carousel of video components and custom interface. When I snap from 1 video to 10+, slider stucks on 6-7th card, but when I set prop windowSize={SCREEN_WIDTH} bug disappeared and I successfully snap from 1 to 40 without stucks.

Tested on iPhone 11, iPhone 6s.

UPD: Yep since it's common flatlist, windowSize eats RAM

Navipro70 avatar Aug 31 '21 11:08 Navipro70

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

dohooo avatar Oct 08 '21 05:10 dohooo

I tried both windowSize and initialNumToRender props but still, it gets stuck on the 6th and 7th item if I call snapToItem(10+)

alirehmanappcrates avatar Nov 23 '21 08:11 alirehmanappcrates