{"version":3,"file":"use-previous.cjs","names":[],"sources":["../../src/hooks/use-previous.ts"],"sourcesContent":["/* eslint-disable react-hooks/refs -- returning last render's value IS this hook's contract */\nimport { useEffect, useRef } from \"react\";\n\n/**\n * Return the value from the previous render. `undefined` on the first render.\n *\n * @example\n * const previousCount = usePrevious(count);\n * useEffect(() => {\n *     if (previousCount !== undefined && previousCount !== count) {\n *         analytics.track(\"count.changed\", { from: previousCount, to: count });\n *     }\n * }, [count, previousCount]);\n */\nexport function usePrevious<T>(value: T): T | undefined {\n    const ref = useRef<T | undefined>(undefined);\n    useEffect(() => {\n        ref.current = value;\n    }, [value]);\n    return ref.current;\n}\n"],"mappings":"uBAcA,SAAgB,EAAe,EAAyB,CACpD,IAAM,GAAA,EAAM,EAAA,OAAA,CAAsB,IAAA,EAAS,EAI3C,OAHA,EAAA,EAAA,UAAA,KAAgB,CACZ,EAAI,QAAU,CAClB,EAAG,CAAC,CAAK,CAAC,EACH,EAAI,OACf"}