import { useEffect, DependencyList } from "react";

export function useDebounceEffect(fn: () => void, waitTime: number, deps?: DependencyList) {
  useEffect(() => {
    const time = setTimeout(() => {
      fn();
    }, waitTime);

    return () => {
      clearTimeout(time);
    };
  }, [deps, fn, waitTime]);
}
