-1

Can anyone tell me what is the minimum and maximum values we can use for debounce in react js?

Thank you.

Rich
  • 155
  • 1
  • 8
  • 23

1 Answers1

2

If I had to guess from the source code

maxWait = maxing ? Math.max(+options.maxWait || 0, wait) : maxWait

Looks like the minimum is 0, and the maximum is probably Number.MAX_SAFE_INTEGER, or 9007199254740991

The Number.MAX_SAFE_INTEGER constant represents the maximum safe integer in JavaScript (2^53 - 1).

Notice the above doesn't explicitly preclude negative maxWait or wait values, but since debounce uses a setTimeout under the hood though, anything less than 0 doesn't really make any sense, i.e. it can't be debounced into the past. Note, however, that setTimeout is throttled to a minimum of once every 4ms.

Reasons for delays longer than specified

So a tighter min-max bound may actually be [4, Number.MAX_SAFE_INTEGER]

Drew Reese
  • 165,259
  • 14
  • 153
  • 181