Is there a way to control sliding in react-multi-carousel

162 Views Asked by At

https://www.npmjs.com/package/react-multi-carousel I'm trying to see if i can be able to control the slide. By default, component itself i handling the next/prev slide. I got a edge case where in some cases i need to prevent the slide. was wondering is there a way to prevent the slide?

1

There are 1 best solutions below

0
On

Add custom arrow buttons, you can do anything base on your requirement before execute onClick

const CustomRightArrow = ({ onClick, ...rest }) => {
  const {
    onMove,
    carouselState: { currentSlide, deviceType }
  } = rest;
  // onMove means if dragging or swiping in progress.
  return <button onClick={() => onClick()} />;
};
<Carousel customRightArrow={<CustomRightArrow />} />;