react-native-snap-carousel icon indicating copy to clipboard operation
react-native-snap-carousel copied to clipboard

Maximum update depth exceeded when loop is true

Open Vadko opened this issue 2 years ago • 3 comments

Is this a bug report, a feature request, or a question?

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?

Both (Write your answer here and specify the iOS/Android versions on which you've been able to reproduce the issue.)

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

Yes

Environment

React: 17.0.1
React native: 0.64.2
react-native-snap-carousel: 3.9.1

Target Platform: Android (10.0) iOS (14.4)

Expected Behavior

Working loop mode

Actual Behavior

App crashes when loop passed as true

simulator_screenshot_02742E43-4F79-427A-9E31-9C1CF725909C

Reproducible Demo

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

Snack example doesnt work for react-native-snap-carousel. It returns error: Cannot read property style of undefined

Steps to Reproduce

const CarouselImage: FC<CarouselImageProps> = ({item}) => {
  const [isImageLoading, setIsImageLoading] = useState(true)
  const onLoadStartImage = () => setIsImageLoading(true)
  const onLoadEndImage = () => setIsImageLoading(false)
  return (
    <View style={styles.wrapper}>
      <Image
        style={styles.image}
        source={{uri: item?.url}}
        resizeMode="cover"
        onLoadStart={onLoadStartImage}
        onLoadEnd={onLoadEndImage}
      />
      {isImageLoading && (
        <ActivityIndicator
          style={styles.imageLoader}
          color={Colors.green}
          size="large"
        />
      )}
    </View>
  )
}

  const restaurant_photos = [
    {
        "url": "https://diningout-dev.s3.amazonaws.com/images/restaurants/Bang Up To The Elephant!/e9535f1f-fb52-4f91-8713-0dd8408f1796"
    },
    {
        "url": "https://diningout-dev.s3.amazonaws.com/images/restaurants/Bang Up To The Elephant!/8426d038-ad27-482a-8e56-98b1c0617ab5"
    },
    {
        "url": "https://diningout-dev.s3.amazonaws.com/images/restaurants/Bang Up To The Elephant!/54d78642-3bd9-4a09-80b5-753fae26e922"
    }
]

<Carousel
          data={restaurant_photos}
          keyExtractor={item => item.url?.toString()}
          renderItem={({item}: {item: RestaurantPhoto}) => (
            <CarouselImage item={item} />
          )}
          sliderWidth={Dimensions.get('window').width}
          itemWidth={Dimensions.get('window').width}
          sliderHeight={Dimensions.get('window').height * 0.35}
          removeClippedSubviews={true}
          loop={true}
          inactiveSlideScale={1}
        />

Vadko avatar Oct 04 '21 17:10 Vadko

@Vadko Sorry, please allow me to advertise for my open source library! ~ I think this library react-native-reanimated-carousel will solve your problem. It is a high performance and very simple component, complete with React-Native reanimated 2

dohooo avatar Oct 08 '21 04:10 dohooo

Additionally reproduced on iOS. It only seems to happen with certain numbers of items, e.g. 1 works, 2 doesn't, 3 does, 4 does.

jameswilddev avatar Feb 14 '22 13:02 jameswilddev

Facing the same problem. Has anyone solved this issue?

Its something to do with the length of the data and the loopClonsesPerSide

RuzenDev avatar Jul 05 '23 22:07 RuzenDev