meliorence / meliorence/react-native-snap-carousel

useState in onSnapToItem breaks item display

Open
#559 4 comments 4 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?

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 ([]).)

Have you made sure that it wasn't a React Native bug?

Yes, it is an explicit react-native-snap-carousel bug

Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?

It is reproducible in Snack on iOS, iOS 12.2

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

Yes

Environment

Environment:
React: 16.8.3
React native: 0.59.2
react-native-snap-carousel: 3.8.0

Target Platform:
iOS (12.2)

Expected Behavior

While snapping between items, the active item would appear bigger.

Actual Behavior

While using

onScroll={Animated.event([{
            nativeEvent: { contentOffset: { x: scrollValue.current } },
          }])}

with Animated in order to interpolate colors for custom indicator
and also onSnapToItem with hooks calls inside, the snapped item where hooks were called become permanently inactive in terms of bigger display.

Removing onScroll or hooks from onSnapToItem fixes the issue, but I need both methods.
snapbug

Reproducible Demo

This snack

(Paste the link to a Snack example in which the issue can be reproduced. Please follow the guidelines for providing a Minimal, Complete, and Verifiable example.)

Steps to Reproduce

(Write your steps so that anyone can reproduce the issue in the Snack demo you provided.)

  1. Open the Snack
  2. Swipe right, the back
  3. Done< the bug is here

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 by running the linked Snack demo with the reported onScroll Animated.event and onSnapToItem hook usage, then reproduce the swipe-right-and-back sequence. Compare behavior with onScroll or the hooks removed; done means the snapped active item still displays larger while both behaviors remain enabled.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.