maxmarinich / react-alice-carousel

React responsive component for building content galleries, content rotators and any React carousels
MIT License
832 stars 91 forks source link

How to make custom component disabled/hidden? #275

Closed NurulWahedQalqul closed 1 year ago

NurulWahedQalqul commented 1 year ago

Hello, I have two custom components to render the next and previous icons. How can I make them disabled/hidden when there are no more items? Here's my code: image image

Kevin-M-Zaleo commented 1 year ago

you could use a state, tracking the current slideIndex in your ´renderNextButton function´ just add something like

renderNextButton={()=>{
  return (slideIndex+1 !== slides.length &&
    <div>
      Your Button
    </div>)
   }
}
maxmarinich commented 1 year ago

Hi, @NurulWahedQalqul! Accordingly the docs, you can using isPrevSlideDisabled || isNextSlideDisabled props from EventObject. Demo https://maxmarinich.github.io/react-alice-carousel/#events.