question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

horizontal snap does not work in react-native version 0.64, 0.65

See original GitHub issue

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 worked in react-native version 0.63.2 but does not work in 0.64.0, 0.65.0

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

Android only

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

Yes, it’s production build

Environment

Environment: React: 17.0.2 React native: 0.65.1 react-native-snap-carousel: 3.9.1

Expected Behavior

Horizontal snap work

Actual Behavior

Horizontal snap does not work

Reproducible Demo

This problem only occurs in latest react-native versions. skip demo

Steps to Reproduce

  1. problem occurs always in android devices

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:11
  • Comments:8

github_iconTop GitHub Comments

2reactions
27leavescommented, Oct 13, 2021

OK guys I have some news. For me it worked now after updating the lib from 0.65.0 to 0.65.1. So I’m sorry but that probably won’t help you @heekyu-pu. What could help is that I debugged a bit and discovered that - at least in my case - it stopped in the function Carousel._getWrappedRef.

If you change this

    _getWrappedRef () {
        if (this._carouselRef && (
            (this._needsScrollView() && this._carouselRef.scrollTo) ||
            (!this._needsScrollView() && this._carouselRef.scrollToOffset)
        )) {
            return this._carouselRef;
        }
        // https://github.com/facebook/react-native/issues/10635
        // https://stackoverflow.com/a/48786374/8412141
        return this._carouselRef && this._carouselRef.getNode && this._carouselRef.getNode();
    }

to just

    _getWrappedRef () {
        return this._carouselRef;
    }

it worked for me. Not sure though if you can safely do that for all cases.

0reactions
poulou0commented, Apr 20, 2022

Setting the decelerationRate={2} (any value >=2) makes the behavior a bit more predictable. Still not ideal but at least it always snaps in place, in my case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native version Mismatch - Native version: 0.59.5
I fixed the problem with help from github forum. This error was caused in my case by having Android 9 in simulator.
Read more >
Upgrading to new versions - React Native
Upgrading to new versions of React Native will give you access to more APIs, views, developer tools and other goodies.
Read more >
npx react-native run-android build failed - You.com
I get this error when i run npx react-native run-android in folder. Everything is installed, emulator running, USB debuggin enabled, node v12, Pixel...
Read more >
Common bugs in React Native ScrollView and how to fix them
React Native's ScrollView component is ubiquitous, but its implementation can sometimes lead to mistakes. Learn what to look out for here.
Read more >
react-native - npm
A framework for building native apps using React. Latest version: 0.70.6, last published: a month ago. Start using react-native in your ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found