We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5f32a7b commit 19eeb4bCopy full SHA for 19eeb4b
app/utils/misc.tsx
@@ -242,12 +242,15 @@ export function useDoubleCheck() {
242
function debounce<Callback extends (...args: Parameters<Callback>) => void>(
243
fn: Callback,
244
delay: number,
245
-) {
+): (this: ThisParameterType<Callback>, ...args: Parameters<Callback>) => void {
246
let timer: ReturnType<typeof setTimeout> | null = null
247
- return (...args: Parameters<Callback>) => {
+ return function (
248
+ this: ThisParameterType<Callback>,
249
+ ...args: Parameters<Callback>
250
+ ) {
251
if (timer) clearTimeout(timer)
252
timer = setTimeout(() => {
- fn(...args)
253
+ fn.apply(this, args)
254
}, delay)
255
}
256
0 commit comments