akiran / react-slick

React carousel component
http://react-slick.neostack.com/
MIT License
11.77k stars 2.1k forks source link

Slider with only one slide item not displaying properly #2357

Closed andreivictor closed 7 months ago

andreivictor commented 8 months ago

I have a slider with dynamic number of items. At page load, the slider contains only one slide item. The slider does not display properly.

const settings = {
    dots: true,
    slidesToShow: 1,
    slidesToScroll: 1
  };

React Slick version: 0.30.1

Stackblitz demo: https://stackblitz.com/edit/vitejs-vite-zskgbz?file=src%2FImageSlider.jsx

wa1kb0y commented 7 months ago

try to set infinite: false

var settings = {
      dots: true,
      slidesToShow: 2,
      slidesToScroll: 1,
      infinite: false
};
andreivictor commented 7 months ago

Thank you, using infinite: false solved the issue.

const settings = {
    dots: true,
    slidesToShow: 1,
    slidesToScroll: 1,
    infinite: false,
  };