// src/hooks/useLiveRef.tsx
import { useCallback, useMemo, useRef, useState } from "react";
var 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);
    }
  }, []);
  const value = useMemo(
    () => [ready ? ref : defaultRef, refCb],
    [ready, ref, refCb]
  );
  return value;
}

export {
  useLiveRef
};
