From 8c66abe9ca0459c40ee649421bc121b8e1b5a62f Mon Sep 17 00:00:00 2001 From: streamich Date: Wed, 19 Dec 2018 23:06:01 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20use=20Timeout=20type=20fo?= =?UTF-8?q?r=20build=20to=20work?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/useDebounce.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/useDebounce.ts b/src/useDebounce.ts index 43003c2704..7db978c274 100644 --- a/src/useDebounce.ts +++ b/src/useDebounce.ts @@ -1,11 +1,11 @@ import { useState, useEffect } from 'react'; const useDebounce = (fn: () => any, ms: number = 0, args: Array = []) => { - const [timeout, setTimeoutVar] = useState(-1); + const [timeout, setTimeoutVar] = useState(null); useEffect(() => { // if args change then clear timeout - clearTimeout(timeout); + clearTimeout(timeout!); const t = setTimeout(fn.bind(null, args), ms); setTimeoutVar(t); }, args);