React-native-snap-carousel: Carousel renderItem is getting called multiple times

Created on 14 Dec 2020  路  6Comments  路  Source: meliorence/react-native-snap-carousel

carousel component render item method gets called multiple times even though the data passed to carousel has only 3 items in the array list.
ScreenShot of the logs -->

Screen Shot 2020-12-14 at 12 31 22 PM

Here is the sample code

renderProductItem = (item) => {
    console.log("item --",item)
    return (
        <Product product={item.item} />
    )
}

render () {
    return (
        <Carousel
          ref={(c) => { this._carousel = c; }}
          data={data}
          renderItem={(item) => this.renderProductItem(item)}
          keyExtractor={item => item.name}
          sliderWidth={Dimensions.get('window').width}
          itemWidth={Dimensions.get('window').width/2}
        />
    );
}

Most helpful comment

Same problem +1

All 6 comments

I had the same problem, but it only happened from card 1 to 5
Testing many options, I tried
useScrollView = {True}
and problem solved in my case.

I had the same problem, but it only happened from card 1 to 5
Testing many options, I tried
useScrollView = {True}
and problem solved in my case.

I think this will make performance problem.. but it fix the problem

It is still the same. it is causing performance issue as render methods called multiple times.

Same problem +1

@bd-arc Is version 3 still being supported? We're experiencing this issue after upgrading React Native to latest version (currently 0.63.4)

@Gustavo-Kuze Unfortunately, I no longer have time to maintain the plugin and am progressively moving away from development. In fact, I've been looking for maintainers for more than a year now.

However, I worked on version 4 last year and it's a huge improvement in many aspects. I recommend that you check the beta version and post any feedback there: https://github.com/meliorence/react-native-snap-carousel/pull/678

Was this page helpful?
0 / 5 - 0 ratings