{"version":3,"file":"use-stable-callback.cjs","names":[],"sources":["../../src/hooks/use-stable-callback.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useLatestRef } from \"./use-latest-ref\";\n\n/**\n * Returns a stable function reference that always invokes the latest\n * `callback` argument. Use to break dependency cycles in effects without\n * triggering re-runs when the callback identity changes.\n *\n * Built on {@link useLatestRef}, which owns the render-time assignment and the\n * reason it is not an effect: an effect would satisfy the React Compiler rules\n * but open a one-commit staleness window. What this adds is the callable with a\n * stable identity, so callers do not reach through `.current`. Prefer React's\n * `useEffectEvent` once it ships as stable.\n *\n * The ref is listed as a dependency because it is one — a stable object across\n * renders, so the returned identity never changes. Listing it is what lets the\n * exhaustive-deps rule verify that instead of taking an empty array on trust.\n */\nexport function useStableCallback<TArgs extends unknown[], TReturn>(\n    callback: (...args: TArgs) => TReturn,\n): (...args: TArgs) => TReturn {\n    const ref = useLatestRef(callback);\n    return useCallback((...args: TArgs) => ref.current(...args), [ref]);\n}\n"],"mappings":"+DAkBA,SAAgB,EACZ,EAC2B,CAC3B,IAAM,EAAM,EAAA,aAAa,CAAQ,EACjC,OAAA,EAAO,EAAA,YAAA,EAAa,GAAG,IAAgB,EAAI,QAAQ,GAAG,CAAI,EAAG,CAAC,CAAG,CAAC,CACtE"}