Skip to content

Strange behaviour when loop is enabled and data is dynamic! #469

@preko96

Description

@preko96

Bug report (iOS)

criteria :
data is dynamic (like I got an initial length of 1, but the length gonna be change to 5 after 1 sec), and the loop is on.

behaviour:
after the number of rendered images changes, the carousel (gonna scrollTo) gonna render the last image, then the first again. (like it's not sure what to do).

possible workaround:
adding a key={data.length} to the Carousel, but of course that gonna destroy, and remount the component what is heavy and cause flickering.

<Carousel
   loop
   data={urls}
   renderItem={this._renderItem}
   slideStyle={{ width: viewportWidth }}
   sliderWidth={viewportWidth}
   itemWidth={viewportWidth}
   inactiveSlideOpacity={1}
   inactiveSlideScale={1}
   onSnapToItem={this.onSnapToItem}
   activeSlideAlignment="center"
/>

Environment:
React: 16.7
React native: 0.57.4
react-native-snap-carousel: 3.7.5

Target Platform:
iOS (12.1)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions