简体   繁体   English

React-slick reinit

[英]React-slick reinit

I'm using react-slick slider and can't figure out how I can re-initialize the slider.我正在使用 react-slick 滑块,但不知道如何重新初始化滑块。 With the jquery slick plugin, I can call $slick.reInit(), but using react I can't seem to do this.使用 jquery slick 插件,我可以调用 $slick.reInit(),但是使用 react 我似乎无法做到这一点。 Is there something similar I can do in react to the reinit method?我可以做类似的事情来对 reinit 方法做出反应吗?

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如果你用一个组件包装 Slick 并给它一个唯一的键,每次键更改时都会重新加载 Slick

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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