You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I have a carousel with autoplay = true and with 3 elements per slide, and i use ref to render the carousel when it is visible in window,
I need to reset the index to 0 every time the component is visible.
I would recommend controlling the index of the carousel yourself, with a useState to hold the index and you can pass it into the Carousel with its index prop.
This way, you can set index to 0 and control it with the Navigation Button callback functions with something like setIndex(index++); on next and setIndex(index--); on prev.
Activity
confrodog commentedon Apr 4, 2025
does a useEffect not solve this problem?
SamehArmouche commentedon Apr 7, 2025
No, because i need reanimation the component when it visible in window
confrodog commentedon Apr 7, 2025
I would recommend controlling the index of the carousel yourself, with a useState to hold the index and you can pass it into the Carousel with its
indexprop.This way, you can set index to 0 and control it with the Navigation Button callback functions with something like
setIndex(index++);on next andsetIndex(index--);on prev.