meliorence / meliorence/react-native-snap-carousel
Different type of data rendered items in wrong order when `loop` is true
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.5k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
version:
"react": "16.9.0",
"react-native": "0.61.2",
"react-native-snap-carousel": "^3.8.2",
code:
<Carousel
loop
data={data}
itemWidth={width}
sliderWidth={width}
renderItem={this.renderItem}
/>
which the data is:
const data = [
{type: 'a', uri: 'https://tmp.mp4'},
{type: 'b', uri: 'https://tmp.png'},
{type: 'b', uri: 'https://tmp2.png'},
{type: 'b', uri: 'https://tmp3.png'},
{type: 'b', uri: 'https://tmp4.png'},
]
and the renderItem:
if (item.type === 'a') {
return (
<View style={{width, height: widht, backgroundColor: 'blue'}} />
)
} else if (item.type === 'b') {
return (
<Image
resizeMode="contain"
style={styles.swiperImg}
source={{ uri: `${item.uri}` }}
/>
)
}
When the loop set to true, the first screen of snap-carousel will never be type a view. The currentIndex is 0, and then swipe next screen, the currentIndex turned to 2.
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 reproducing the issue in the Carousel with the supplied mixed-type data and loop enabled, then trace the loop and currentIndex handling. Confirm that the initial item is the type 'a' view and that swiping advances to the correct next item rather than index 2.
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
- 30/100