meliorence / meliorence/react-native-snap-carousel
Prepending items to the data prop changes firstItem
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?
Question and/or a bug report.
Have you followed the required steps before opening a bug report?
- I have read the guidelines regarding bug report.
- [x ] I have reviewed the documentation in its entirety, including the dedicated documentations 📚.
- [x ] I have searched for existing issues and made sure that the problem hasn't already been reported.
- [ x] I am using the latest plugin version.
- [ x] 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?
I believe so.
Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?
Only testing in iOS at the moment
Is the bug reproductible in a production environment (not a debug one)?
Have not tried in production.
Environment
React: 16.8.3
React native: 0.59.5
react-native-snap-carousel: 3.7.5
Expected Behavior
For performance with a large data list I am basically doing what is described in this issue: https://github.com/archriss/react-native-snap-carousel/issues/384
I am managing a smaller list specifically for in the data prop. I am handling infinite scrolling/pagination manually by detecting the start and end indexes in onBeforeSnapToItem. I want to be able to land in the middle of a list of items and as I swipe right AND left, new items will be loaded into the list in regards to the direction I was swiping (prepending or appending)
Actual Behavior
It works fine for when you are swiping forward (or 'right') and you reach the end. I append the new items in the list and everything is okay.
The issue is when you swipe backwards (or left) and load some more data. I prepend the data to the list and the firstItem is completely lost and the carousel renders the very first item in the list, which is incorrect. The firstItem prop should remain unchanged when prepending data to the list.
Reproducible Demo
I will provide a reproducible demo if needed. I wanted to ask to see if you knew a quick solution or if this was a limitation of FlatList.
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 with the Carousel data, firstItem, and onBeforeSnapToItem behavior described in the report, then inspect how the underlying FlatList responds when items are prepended. Reproduce the case on iOS with react-native-snap-carousel 3.7.5, beginning from a middle item and loading items while swiping backward. Done means the carousel preserves the selected firstItem after prepending while existing forward pagination still works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100