meliorence / meliorence/react-native-snap-carousel

[BUG] carousel not showing correct first item

Open
#939 5 comments 3 reactions 0 assignees View on GitHub

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?

Yes, Bug report

Have you followed the required steps before opening a 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?

This is specific to both the platforms

Is the bug reproductible in a production environment (not a debug one)?

Yes

Environment

Environment:
React: 16.13.1
React native: 0.63.2
react-native-snap-carousel: 3.9.1

Target Platform:
Android (12.0)
iOS (15.5)

Expected Behavior

When using the carousel with enabling loop, and setting loopClonesPerSide to 1, the initial first item shown in expected to be the first item of data.
Screenshot 2022-08-17 at 12 30 30 PM

Actual Behavior

When component renders for the first time it is not showing the first item of the data prop.
Screenshot 2022-08-17 at 12 27 41 PM

Here I am passing exactly 2 item to each carousel. I want to show the first item first and then second item as per the image in the expected behaviour.

I tried setting firstItem to 0, 1, 2 but in all the case it is not working as expected.

Reproducible Demo

Carousel implementation:

<Carousel
  ref={carouselRef}
  data={carouselItemList}
  loop={true}
  loopClonesPerSide={1}
  enableSnap={true}
  renderItem={renderItem}
  scrollEnabled={false}
  onSnapToItem={handleOnSnapToItem}
/>
Steps to Reproduce
  1. Implement the carousel as I mentioned above.
  2. Give it exactly array of 2 items.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided carousel implementation and reproduce it on Android or iOS using exactly two data items, loop enabled, and loopClonesPerSide set to 1. Trace the initial item selection and verify that the first data item is shown on the first render before the second item.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.