"use client";
import { useIsoLayoutEffect } from "./useIsoLayoutEffect.js";
import { useRefWithInit } from "./useRefWithInit.js";
function useValueAsRef(value) {
  const latest = useRefWithInit(createLatestRef, value).current;
  latest.next = value;
  useIsoLayoutEffect(latest.effect);
  return latest;
}
function createLatestRef(value) {
  const latest = {
    current: value,
    next: value,
    effect: () => {
      latest.current = latest.next;
    }
  };
  return latest;
}
export {
  useValueAsRef
};
//# sourceMappingURL=useValueAsRef.js.map
