0

I'm trying to use React Slick to display several cards. I want that on entering the page with the slider this will slide to the selected/highlighted slide. But I cannot find a way to get an index or identifier from the react-slider, maybe I'm missing some information.

All the examples show a way to track slides, but for my case (at least I think so) I'll need to have them already indexed so I can target the one I want. Any ideas?

Henrique
  • 31
  • 4
  • I'm not sure if I'm understanding your question correctly: you probably have the data at hand that you pass to React Slick to display those cards: so from the data itself you already know the indices of each entry, and also the total number of cards. Is there a reason why you need a roundabout approach to get an index from React Slick? – Terry Feb 19 '22 at 23:27
  • slick has a `slickGoTo` method that allows you go to whatever slide you want. https://react-slick.neostack.com/docs/api#slickGoTo If you're mapping the array, you can use the 2nd argument to get the index of the element being mapped. e.g. `Array.map((item, idx) => ` Can you post your full code so we can help you? – Joel Hager Feb 19 '22 at 23:55

0 Answers0