简体   繁体   中英

React-slick reinit

I'm using react-slick slider and can't figure out how I can re-initialize the slider. With the jquery slick plugin, I can call $slick.reInit(), but using react I can't seem to do this. Is there something similar I can do in react to the reinit method?

There is no such feature for now, but there is a way to do it.

If you wrap Slick with a component and give it a unique key, slick reloads each time the key changes

render: function() {
    return <div key={uniqueId}>
               <CarouselComponent>
           </div>;
}

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