Song Hoàng
Song Hoàng

Reputation: 41

Keen-slider doesn't work well with Server-side render on the first render - NextJS

I am using nextJS with typescript and got 1 error when using the keen-slider library v5.4.0. The error occurs when the keen-slider is rendered for the first time, the items are not of the same type transform when I drag the slider. It causes items to be stacked on top of each other. Has anyone come across such a case? Please let me know anything that can fix it. Thank you all.

Upvotes: 1

Views: 3127

Answers (1)

Song Hoàng
Song Hoàng

Reputation: 41

I fixed the above by upgrading to keen-slider version 6.6.14.

npm i [email protected]

And add this code below

const [internalSliderRef, internalSlider] = useKeenSlider(sliderOptions);

  React.useEffect(() => {
    internalSlider.current?.update({
      ...sliderOptions
    });
  }, [internalSlider, sliderOptions]);

Thank for all

Upvotes: 3

Related Questions