简体   繁体   中英

React-slick carousel - autoplay not working in child component while triggering it with prop from parent component

I m using React. I am trying to implement a carousel and I tried to trigger auto play option(props for Slider literally) in react-slick , the autoplay in react-slick is not working.

I had used react-slick 0.23.1 which it doesn't work

Later I tried with react-slick 0.21.0 it did work

Thanks!

Give a reference to the tag.

<Slider ref={slider => (this.slider = slider)}>
 ...
</Slider>

You can use the slickPause() & slickPlay() functions

play() {
  this.slider.slickPlay();
}

pause() {
  this.slider.slickPause();
}

https://github.com/akiran/react-slick/blob/master/examples/AutoPlayMethods.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM