From 23d6a5af785ddc5796a402fb41e24f680341e06e Mon Sep 17 00:00:00 2001 From: Ward Date: Thu, 26 Sep 2019 10:14:31 +0200 Subject: [PATCH] fix: useDebounce remove deps from function arguments (#623) --- src/useDebounce.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/useDebounce.ts b/src/useDebounce.ts index 3c7d4664ca..bb7bffb7af 100644 --- a/src/useDebounce.ts +++ b/src/useDebounce.ts @@ -1,14 +1,14 @@ +import { DependencyList } from 'react'; import useUpdateEffect from './useUpdateEffect'; -const useDebounce = (fn: () => any, ms: number = 0, args: any[] = []) => { +const useDebounce = (fn: () => any, ms: number = 0, deps: DependencyList = []) => { useUpdateEffect(() => { - const handle = setTimeout(fn.bind(null, args), ms); + const timeout = setTimeout(fn, ms); return () => { - // if args change then clear timeout - clearTimeout(handle); + clearTimeout(timeout); }; - }, args); + }, deps); }; export default useDebounce;