firstItem doesn't work reliably
See original GitHub issueIs this a bug report, a feature request, or a question?
Bug report
Have you followed the required steps before opening a bug report?
(Check the step you’ve followed - put an x
character between the square brackets ([]
).)
- I have read the guidelines regarding bug report.
- I have reviewed the documentation in its entirety, including the dedicated documentations 📚.
- I have searched for existing issues and made sure that the problem hasn’t already been reported.
- I am using the latest plugin version.
- I am following the issue template closely in order to produce a useful 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?
It’s reproducible on both platforms but has slightly different behaviour on each. On iOS index 14 is shown, on Android, index 6 is shown, when firstItem
is 30
.
Is the bug reproducible in a production environment (not a debug one)?
Yes
Environment
Here’s a snack which reproduces the behaviour: https://snack.expo.io/@thekevinbrown/snap-carousel-first-item-bug
That environment’s details: react-native-snap-carousel: 3.8.0 Expo v33.0.0
Expected Behavior
Expected carousel to load with a green screen focused (slide index 30)
Actual Behavior
Carousel loads with slide index 14 focused or 6 focused depending on platform.
Reproducible Demo
https://snack.expo.io/@thekevinbrown/snap-carousel-first-item-bug
Steps to Reproduce
- Load more than a few pages of any type of slide into snap-carousel
- Set firstItem to a number > 14
- Carousel starts on various indexes which are not the one you passed in as a prop.
Other Notes
I commented with this snack on #496, but I don’t think it was noticed, and is likely to be a different issue now that I read that issue more closely, so I figured I’d open a new one. Thanks for your help!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:32 (6 by maintainers)
Top GitHub Comments
@thekevinbrown Hi, I have the same issue, i resolve this in use initialNumToRender={data.length}, but i slow performance
@thekevinbrown Did you pass to the
Carousel
component the relevantgetItemLayout
&initialScrollIndex
properties for your use-case? for example:The branch just enables usage of them, so using the branch without implementing the props wouldn’t make any change. I haven’t tested your snack specifically but I’ve reproduced exactly the same issue and now it’s resolved also in my production environment on bigger lists. LMK how it goes