Skip to content

Commit

Permalink
fix: πŸ› use Timeout type for build to work
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Dec 19, 2018
1 parent 244a533 commit 8c66abe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/useDebounce.ts
@@ -1,11 +1,11 @@
import { useState, useEffect } from 'react';

const useDebounce = (fn: () => any, ms: number = 0, args: Array<any> = []) => {
const [timeout, setTimeoutVar] = useState<number>(-1);
const [timeout, setTimeoutVar] = useState<NodeJS.Timeout | null>(null);

useEffect(() => {
// if args change then clear timeout
clearTimeout(timeout);
clearTimeout(timeout!);
const t = setTimeout(fn.bind(null, args), ms);
setTimeoutVar(t);
}, args);
Expand Down

0 comments on commit 8c66abe

Please sign in to comment.