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.

Custom renderDots components do not trigger snapToItem on press when tappableDots is enabled

See original GitHub issue

Is this a bug report or a feature request?

Bug report

Have you read the guidelines regarding bug report?

Yes.

Have you read the documentation in its entirety?

Yes.

Have you made sure that your issue hasn’t already been reported/solved?

Yes.

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

I’ve only tested it on iOS.

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

I’m unsure.

Have you been able to reproduce the bug in the provided example?

Yes.

Environment

Environment: React: 16.2.0 React native: 0.52.0 react-native-snap-carousel: 3.6.0

Target Platform: iOS (11.2)

Steps to Reproduce

(Write your steps here:)

  1. create a Carousel, with its ref callback assigning to this.carouselRef
  2. create a Pagination, with tappableDots, carouselRef, and a custom renderDots:
  <Pagination
    containerStyle={{
      flexDirection : 'row',
      height : 50,
      paddingTop : 0,
      paddingBottom : 0
    }}
    renderDots={ activeIndex => (
      IONICON_NAMES.map((ioniconName, i) => (
        <View
          style={{ flex : 1, alignItems : 'center' }}
          key={ i }
        >
          <Ionicons
            name={ ioniconName }
            color={ i === activeIndex ? '#4a90e2' : '#000' }
            size={ 30 }
          />
        </View>
      ))
    )}
    activeDotIndex={ this.state.activeTab }
    dotsLength={ 3 }
    tappableDots={ !!this.carouselRef }
    carouselRef={ this.carouselRef }
  />

Expected Behavior

Before implementing a custom renderDot component, tapping on a given dot would trigger the correct snapToItem method call. With the custom renderer, tapping on a given tab (custom dot) does not result in the same behavior.

Actual Behavior

There is no error message. From renderDot’s 3 available parameters (activeIndex, total, context), none contains the snapToItem method. If they did, I’d be able to pass this method to the dot components. I originally thought that react-native-snap-carousel would, behind the scenes, wrap the custom dot components with onPress callbacks. But it appears that using dotRenderer overrides the tappableDots behavior altogether.

Reproducible Demo

Here’s the Snack 🥇

screen shot 2018-02-22 at 7 04 07 pm

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
bd-arccommented, Feb 25, 2018

Hey @harrysolovay,

I haven’t made it clear in the doc, but when you use the renderDots prop, dots’ onPress logic is lost and you need to provide yours. I admit that this can be pretty confusing and I’ll fix this in the next release.

For now, I’ve updated your Snack example and brought in the logic of the PaginationDot component 😉

You can find it here: https://snack.expo.io/SkG6Agluz

0reactions
marcus-o-fintroncommented, Jun 8, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom renderDots components do not trigger snapToItem on ...
Before implementing a custom renderDot component, tapping on a given dot would trigger the correct snapToItem method call.
Read more >
React native - how to set this state with hooks instead of 'this ...
Alrighty, I have a Snack Im trying to convert to using functional components / hooks. Am new to the logic ...
Read more >
react-native-snap-carousel/CHANGELOG.md - UNPKG
27, * Fix issue with tappable dots when loop is enabled. 28. 29, ## v3.4.0. 30, * Fix `snapToItem` call that results in...
Read more >
react-native-snap-carousel - npm
Swiper/carousel component for React Native with previews, multiple layouts, parallax images, performant handling of huge numbers of items, ...
Read more >
Dhtmlxlayout Cell Scroll Clipart
Custom renderDots components do not trigger snapToItem on press when tappableDots is enabled · Issue #273 · meliorence/react-native-snap-carousel · GitHub ...
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