import { useCallback, useMemo, useRef, useState } from "react";
//#region src/hooks/useLiveRef.tsx
const defaultRef = { current: null };
function useLiveRef() {
	const [ready, setReady] = useState(false);
	const ref = useRef(null);
	const refCb = useCallback((node) => {
		if (node !== null) {
			ref.current = node;
			setReady(true);
		}
	}, []);
	return useMemo(() => [ready ? ref : defaultRef, refCb], [
		ready,
		ref,
		refCb
	]);
}
//#endregion
export { useLiveRef };
