meliorence / meliorence/react-native-snap-carousel
When nesting carousel, can't snapToItem with ref of inner carousels
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.5k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
Is this a bug report, a feature request, or a question?
Might not be a bug but rather a usage different than intended.
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. This is related to the looping behavior of Carousel.
Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?
It happens on both.
Is the bug reproductible in a production environment (not a debug one)?
I couldn't find production mode on Snack.
Environment
Environment:
Expo: 39.0.5
React: 16.13.1
React native: 0.63.2
react-native-snap-carousel: 3.9.1
Happens to Expo 40 with react-native-snap-carousel 4.0.0-beta.6 too
Target Platform:
Android (whichever version Snack used)
iOS (14)
Expected Behavior
I'm nesting horizontal carousels inside a vertical carousel to create a grid system. Both dimensions allow looping. There will be buttons that let users jump to a specific screen.
Actual Behavior
It jumps to the correct row but not the correct column. (This happens to a different example from the demo below) After you jump, without changing the column, change the row in one direction and stop before it loops back to the wanted row. Peeking the wanted row, you might see the correct column. But it will change when you actually move to that row.
Reproducible Demo
https://snack.expo.io/@jloq/react-native-snap-carousel-nested-carousel
Press the text to jump. Every text jumps to 1, 1.
I believe the problem is that enabling looping made the innerRef in line 34 different than the snapped item of line 33. I already have a workaround of disabling looping in the outer carousel but looping is still preferable.
Steps to Reproduce
- Nest horizontal carousels inside a vertical carousel. Enable looping in all of them.
- Obtain the refs of them.
- Try to snap to a different row and column.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the linked Expo Snack and reproducing nested horizontal carousels inside a looping vertical carousel. Inspect the innerRef and snapped-item usage around lines 33–34 in the demo, then trace the carousel ref and looping behavior in the repository. Done means programmatic snapping selects both the requested row and column while looping remains enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- frontend, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100