react-native-snap-carousel: this._scrollRef.scrollTo is not a function (nested carousels)

Hi!

I’m getting the above error when initializing my carousel! I’ve got the JSX for it below.

Fun fact - I’m actually instantiating this inside something that’s already within a larger Carousel component. Could that be causing the above error?

<Carousel
  data={heroImages}
  itemWidth={heroImageWidth}
  sliderWidth={parentCardWidth - 30}
  ref={d => {
    this._carousel = d;
  }
  renderItem={(item, idx) => {
    return (
      <View style={{ width: heroImageWidth }}>
         <Text>hi</Text>
      </View>
    );
  }}
/>

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 4
  • Comments: 19 (8 by maintainers)

Most upvoted comments

useScrollView for nested carousel worked in my case. Thanks @bd-arc

Unfortunately, we can’t be sure that a solution can be found since the issue comes from the FlatList component and not from the plugin.

Note that a prop useScrollView has been introduced in version 3.5.0. I recommend that you try to activate it for both your carousels; maybe the issue won’t show up when using an animated ScrollView instead of an animated FlatList.

If you need us to dig deeper into the issue, please create an example that reproduces the bug using https://snack.expo.io/ and provide us with the link.

After running into this I tried nesting FlatList inside a Carousel component and found it similarly buggy. However, as guilharj mentioned above, ScrollView seems to be fine.