{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "use-composed-ref",
  "title": "useComposedRef",
  "description": "Keeps a ref to your own element while still forwarding it to whatever ref the parent passed in.",
  "files": [
    {
      "path": "hooks/use-composed-ref.ts",
      "content": "import * as React from \"react\"\n\nfunction useComposedRef<T>(ref: React.Ref<T> | undefined) {\n  const inner = React.useRef<T | null>(null)\n  const setRef = React.useCallback(\n    (node: T | null) => {\n      inner.current = node\n      if (typeof ref === \"function\") {\n        ref(node)\n      } else if (ref) {\n        ref.current = node\n      }\n    },\n    [ref]\n  )\n  return [inner, setRef] as const\n}\n\nexport { useComposedRef }\n",
      "type": "registry:hook"
    }
  ],
  "type": "registry:hook"
}