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.

Carousel with dynamic data

See original GitHub issue

I’m using your carousel project. I wanted to bind 1000 items to carousel. My code works, but when i update state of carouselData, app is waiting almost 10 seconds. This wait is so long for user experience. And carousel strange behaviour. Like this video. I want to pass one by one. How can i fast update data. I bind data like this on onSnapToItem event:

<Carousel
             ref={(c) => { this.carousel = c; }}
             data={this.state.carouselData}
....
 onSnapToItem={(index) => {
    if(index%4==0)
    {
          const lastArr = this.arrContent.slice(index + 1, index + 6);
          this.setState({
                           carouselData: [...this.state.carouselData, ...lastArr]
           });
     }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
SaraChicaDcommented, May 22, 2019

The issue I’m getting with dynamic data is that I’m trying to always have a set of 3 items, swap out the first and last, but then Carousel never recognizes that there are more than 3 items in the array.

Does anyone have an example of how they solved this or got around it?

So I have this: data = [first, second, third] and I have logic that’s constantly updating all three images, but the Carousel will only ever let me swipe to the 3 items.

0reactions
bd-arccommented, Nov 1, 2017

@egvrcn You’re welcome! Thanks for the feedback on shouldComponentUpdate by the way.

I’m going to close the issue because there is only so much we can do about it. Let’s follow FlatList’s evolution closely and post any meaningful update to this thread 😉

I’ll make sure to add everything we’ve shared so far to the doc; it can prove useful for other users.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic product carousels | Algolia
Display search results in carousels. The dynamic carousel lets you change the list of carousels from the dashboard without editing the front ...
Read more >
Dynamic carousel with dynamic content | Mendix Forum
Greetings, I need a dynamic carousel where I can have any number of slides. Example: could have either 2 slides or 20 slides...
Read more >
Carousel - dynamic - CodePen
1. var carousel = document.querySelector('.carousel'); ; 2. var cells = carousel.querySelectorAll('.carousel__cell'); ; 3. var cellCount; // cellCount set from ...
Read more >
how to create a a bootstrap Carousel with dynamic image ...
the first image in bootstrap carousel requires it to be active so just put a ternary operator to check for index and if...
Read more >
Bootstrap Dynamic Carousel on Codeply
Dynamic Bootstrap Carousel with jQuery Codeply example.
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