React-native-snap-carousel: Question: is there a warmup time?

Created on 20 Feb 2019  路  6Comments  路  Source: meliorence/react-native-snap-carousel

question: sometimes .snapToItem(index) fails

I call this.carousel.snapToItem(index) within componentDidUpdate(). This sometimes works, but sometimes doesn't (to "fix" this I put the call in the setTimeout).

I was just wondering if there was a "warm up" time for the carousel (or the underlying Views).

And if so, how can I check that it is "ready".

Thanks

Most helpful comment

Yeah, I have the same issue. I don't really know why that is happening. Prob the is a race condition that make that strange behavior to happen.

All 6 comments

I have same issue and it turns out that renderItem function in carousel is excuted after componentDidMount of parent component is excuted. I guess same thing would happen for the componentDidMount. I couldn't figure out how to avoid this issue except setTimeout yet

I have the same issue, is there no better way around this?

you should try using firstItem props:

<Carousel
  firstItem={2}
/>

Yeah, I have the same issue. I don't really know why that is happening. Prob the is a race condition that make that strange behavior to happen.

I am also running into this problem. Has anyone managed to make progress?

Struggling with this too, any help would be very much appreciated.

Was this page helpful?
0 / 5 - 0 ratings