noUiSlider rerenders when moving slider
Hello, I have an issue with noUiSlider(https://refreshless.com/nouislider/) i want to make a slider with 2 knobs. Everytime i move a knob on the slider, i get the following error message in the console.
Uncaught Error: noUiSlider: Slider was already initialized.
the code looks like this
Any idea what is wrong? Much appreciated.
noUiSlider - JavaScript Range Slider | Refreshless.com
noUiSlider is a lightweight, ARIA-accessible JavaScript range slider with multi-touch and keyboard support. Great for responsive designs, and no dependencies!
2 Replies
I made it work with the help of chat gpt, lol. In case anybody is interested in the solution it looks like this:
The issue with the original code is that it uses createEffect instead of onMount, and that it returns a cleanup function (like you would in react, but that doesn't work in solid) instead of using the onCleanup function
In your corrected code, you fixed those issues, though you didn't need to use a ref function to fix it (though it's fine either way)