import { useEffect } from "react";

export const useDebouncedEffect = (effect, deps = [], delay = 250) => {
  useEffect(() => {
    const rid = setTimeout(() => effect(), delay);
    return () => clearTimeout(rid);
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [delay, ...deps]);
};
