Using custom arrows you can get the className property on custom arrow component, react-slick add the class slick-disabled
to that arrow when it does not have more slide to show, so with that in mind you can check className?.includes("slick-disabled")
, more details following:
import React from "react";
import Slider from "react-slick";
const NextArrow: React.FC<ArrowsProps> = ({ onClick, className }) => (
<ArrowRightContainer onClick={onClick} isDisabled={className?.includes("slick-disabled")}>
<Icon name="chevron-right" />
</ArrowRightContainer>
);
const PrevArrow: React.FC<ArrowsProps> = ({ onClick, className }) => (
<ArrowLeftContainer onClick={onClick} isDisabled={className?.includes("slick-disabled")}>
<Icon name="chevron-right" styles={ArrowLeftIcon} />
</ArrowLeftContainer>
);
const settings = {
infinite: false,
speed: 350,
slidesToShow: 4,
slidesToScroll: 1,
nextArrow: <NextArrow />,
prevArrow: <PrevArrow />,
};
<Slider {...settings}>
.....
</Slider>