0

I have such function (I'm using debounce from lodash):

    const sliderDebounce = debounce(() => {
        postSliderVal({ email_instances }) //POST 
    }, 1000);

I guess it should send 1 request after 1 second but it send a lot of requests, how I can send 1 request when I will change the slider value?

  • You are debouncing your arrow function, not the `postSliderVal()` function. Remove the arrow function wrapper. – Randy Casburn Oct 14 '20 at 12:45
  • @RandyCasburn in this case i have such problem Uncaught TypeError: Expected a function – stack overflow Oct 14 '20 at 13:04
  • You defined it just fine - https://jsbin.com/munanaz/edit?html,js,console,output. The issue is probably because that you use hooks. A [similar question](https://stackoverflow.com/q/54666401/863110) (it's about `throttle` but it applies `debounce` too) – Mosh Feu Oct 14 '20 at 14:55

0 Answers0