brainhubeu / react-carousel

A pure extendable React carousel, powered by Brainhub (craftsmen who ❤️ JS)
https://brainhub.eu/
MIT License
1.07k stars 164 forks source link

onChange won't fire in version 2.0.2 #676

Closed kiuka closed 3 years ago

kiuka commented 3 years ago

Describe the bug Hey guys, I'm trying to setup a carousel, but I have faced some issues with the latest version (2.0.2).

First of all it fills the console with warnings:

image

And my other problem is that the onChange event never fires. I have created a small snippet: https://codesandbox.io/s/jovial-antonelli-6gz7l it should log the changes to the console, but it doesnt do anything when I change between the slides.

This seems like a core function, it's weird that it doesn't work, any idea what am I missing?

MBogdan18 commented 3 years ago

You need to add the value prop to the Carousel component in order to get the value from the onChange method prop. As for the console warnings, I don't have a solution for that as I'm struggling with it myself.

Also, since the issue's title seems to be relevant to my problem, I will also add that onChange doesn't fire when the autoplay plugin is added into the mix. This for instance doesn't set the active dot when sliding through images automatically.

RobertHebel commented 3 years ago

as @MBogdan18 you need to provide value prop in order to make onChange work

regarding onChange with autoplay plugin, the issue has been fixed in v2.0.3