Closed tkroll closed 6 years ago
thanks @tkroll
supplement hooks version:
const ref = useRef() as any;
<button type="button" onClick={() => ref.current.slider.goTo('prev')}>
Previous
</button>
<button type="button" onClick={() => ref.current.slider.goTo('next')}>
Next
</button>
<TinySlider
settings={settings}
ref={(ts) => {
ref.current = ts;
}}
>
...
</TinySlider>
Just wanted to share how to use external buttons for prev & next
Get the slider from refs:
Add onClick for your buttons:
Add the handler on your component:
Hope this helps someone. It's a decent alternative when handed code using Slick.
Thanks to @jechav for React-ifying this.