import { debounce } from "lodash-es";
import { useEffect, useState } from "react";
//#region src/hooks/useDebounce.tsx
function useDebounce(value, delay = 0, options) {
	const [current, setCurrent] = useState(value);
	useEffect(() => {
		const debounced = debounce(() => {
			setCurrent(value);
		}, delay, options);
		debounced();
		return () => {
			debounced.cancel();
		};
	}, [
		value,
		delay,
		JSON.stringify(options)
	]);
	return current;
}
//#endregion
export { useDebounce };
