{"version":3,"file":"use-latest.cjs","sources":["../../src/utils/use-latest.ts"],"sourcesContent":["import type { MutableRefObject } from \"react\";\nimport { useEffect, useRef } from \"react\";\n\n/**\n * Keeps a ref in sync with a given value that may or may not change on\n * every render.\n *\n * The purpose of this hook is to return a stable ref that can be passed\n * to a callback function so the callback can be registered but still can\n * access the latest value at a later point in time.\n */\nexport function useLatest<T>(value: T): MutableRefObject<T> {\n  const ref = useRef(value);\n  useEffect(() => {\n    ref.current = value;\n  }, [value]);\n  return ref;\n}\n"],"names":["useRef","useEffect"],"mappings":";;;;AAWO,SAAS,UAAa,KAA+B,EAAA;AAC1D,EAAM,MAAA,GAAA,GAAMA,aAAO,KAAK,CAAA,CAAA;AACxB,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,GAAA,CAAI,OAAU,GAAA,KAAA,CAAA;AAAA,GAChB,EAAG,CAAC,KAAK,CAAC,CAAA,CAAA;AACV,EAAO,OAAA,GAAA,CAAA;AACT;;;;"}