import React from "react";

export function useDebounce(value: string, delay: number = 300) {
  const [debounced, setDebouced] = React.useState(value);
  React.useEffect(() => {
    const handler = setTimeout(() => setDebouced(value), delay);
    return () => clearTimeout(handler);
  }, [value, delay]);

  return debounced;
}
