React-slick: prop / func to return what index of the slider you are at?

Created on 11 Mar 2019  路  1Comment  路  Source: akiran/react-slick

I'm looking for robust way of determining whether the slider is at the very-beginning or very-end of the gallery.

I'm currently using the afterChange prop, but that returns the index of the particular image it ended at and not where it is on the 'dots'.

I need this functionality to conditionally render my custom arrows depending on the point of the slider / gallery it is in; I can make a PR if this is a feature that is missing

Most helpful comment

I also needed to do some conditional rendering for custom arrows,

you can specify a component in the settings you provide to the slider component for the keys nextArrow and prevArrow and they get passed in style, className, onClick, and some other props from the library itself. Using this I was able to conditionally render different svg's in my component depending on if it was at the beginning, middle, or end of the carousel. react-slick actually did most of the work

const settings = {
  ...,
  nextArrow: <YourComponent ...anyPropsYouWant />,
  prevArrow: <YourComponent ...anyPropsYouWant />,
}

>All comments

I also needed to do some conditional rendering for custom arrows,

you can specify a component in the settings you provide to the slider component for the keys nextArrow and prevArrow and they get passed in style, className, onClick, and some other props from the library itself. Using this I was able to conditionally render different svg's in my component depending on if it was at the beginning, middle, or end of the carousel. react-slick actually did most of the work

const settings = {
  ...,
  nextArrow: <YourComponent ...anyPropsYouWant />,
  prevArrow: <YourComponent ...anyPropsYouWant />,
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

adamthewan picture adamthewan  路  4Comments

amishPro picture amishPro  路  3Comments

rohitgoyal7 picture rohitgoyal7  路  3Comments

eternalsky picture eternalsky  路  3Comments

PolGuixe picture PolGuixe  路  3Comments