Skip to content

Commit

Permalink
refactor: useDebounce ๊ฐœ์„ 
Browse files Browse the repository at this point in the history
  • Loading branch information
feb-dain committed Nov 16, 2023
1 parent 14c93e4 commit bca1638
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions frontend/src/hooks/useDebounce.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useEffect, useCallback } from 'react';

export const useDebounce = <T>(func: (param: T) => void, dependencies: string[], delay: number) => {
const callback = useCallback(func, dependencies);
const callback = useCallback(func, [delay]);

useEffect(() => {
const timeout = setTimeout(callback, delay);

return () => clearTimeout(timeout);
}, [callback, delay]);
}, [callback, dependencies]);
};

0 comments on commit bca1638

Please sign in to comment.