{"version":3,"sources":["../../src/use-getter-ref/index.ts"],"sourcesContent":["import { useRef } from 'react'\nimport { useStableFn } from '../use-stable-fn'\n\nimport type { MutableRefObject } from 'react'\n\nexport type UseGetterRefReturnsGetter<T> = () => T\n\nexport type UseGetterRefReturns<T> = [\n  /**\n   * A mutable ref object that can be used to store a value.\n   */\n  ref: MutableRefObject<T>,\n  /**\n   * A getter function that returns the current value of the ref.\n   */\n  UseGetterRefReturnsGetter<T>,\n]\n\n/**\n * A React Hook that create a gettable ref, a function way to get the latest value of a ref.\n */\nexport function useGetterRef<T>(initial: T): UseGetterRefReturns<T> {\n  const ref = useRef<T>(initial)\n  const getter = useStableFn(() => ref.current)\n  return [ref, getter] as const\n}\n"],"names":["useGetterRef","initial","ref","useRef","getter","useStableFn","current"],"mappings":";;;;+BAqBgBA;;;eAAAA;;;qBArBO;2BACK;AAoBrB,SAASA,aAAgBC,OAAU;IACxC,IAAMC,MAAMC,IAAAA,aAAM,EAAIF;IACtB,IAAMG,SAASC,IAAAA,wBAAW,EAAC;eAAMH,IAAII,OAAO;;IAC5C,OAAO;QAACJ;QAAKE;KAAO;AACtB"}