React-responsive-carousel: Carousel is being restarted unintentionally

Created on 7 Jun 2018  路  6Comments  路  Source: leandrowd/react-responsive-carousel

Hello.
I have a component that holds the carousel and when the the parent of the parent of the carousel state changes the carousel returns to the first image...
the hierarchy is as follows Gallery > GallerySlider > Carousel.
when Gallery state changes Carousel is being reset.
I really have no idea how to start to fix such a thing

wontfix

Most helpful comment

this problem still exists, my way of solving it was using the onChange method to get the newly selected index, keep it in my component state and feed it to selectedItem prop, initialized with 0

All 6 comments

I fixed it by taking the Carousel out of the Gallery components and placing it in the entire page.
I still don't understand why this issue would start in the first place and why cant i nest the Carousel in the gallery components =/

It could be the Gallery is rerendering causing a new Carousel to be created rather than updating it. Is it a public component?

I am not sure what a public component is but I suppose you are right, its what I thought as well, therefore I extracted the carousel into its own component so it wont be affected by re renders caused by the same shared class.
I think this behaviour is not good and should be fixed. Thanks

I meant is it open source public so it can be looked at - is there a link to it and do you have example code which reproduces your problem?.

It does seem at the moment a problem with the Gallery component, not Carousel.

this problem still exists, my way of solving it was using the onChange method to get the newly selected index, keep it in my component state and feed it to selectedItem prop, initialized with 0

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ShineOfFire picture ShineOfFire  路  6Comments

wildpow picture wildpow  路  5Comments

ledbetterljoshua picture ledbetterljoshua  路  6Comments

PatrikKozak picture PatrikKozak  路  3Comments

spk-cpsamut picture spk-cpsamut  路  4Comments