Сделал хук useDebounce
import { useCallback, useEffect, useRef, useState } from "react"
export default function useDebounce(callback, delay: 500) {
const timer = useRef();
const debouncedCallback = useCallback((...args) => {
if(timer.current) {
clearTimeout(timer.current);
}
timer.current = setTimeout(() => {
callback(...args)
}, delay);
}, [callback, delay])
return debouncedCallback;
}
Закинул туда setState
const [minPrice, setMinPrice] = useState(5000);
const debouncedMinPrice = useDebounce(setMinPrice, 500);
const [maxPrice, setMaxPrice] = useState(15000);
const debouncedMaxPrice = useDebounce(setMaxPrice, 500);
И повесил на обработчик в input
<RangeSlider defaultMax={15000} defaultMin={500} maxValue={20000} priceGap={2500} title="Диапазон цены"
onMaxChange={debouncedMaxPrice}
onMinChange={debouncedMinPrice}/>