{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "use-async-effect",
  "title": "useAsyncEffect",
  "description": "A hook to run an async effect",
  "files": [
    {
      "path": "registry/hooks/use-async-effect.ts",
      "content": "'use client'\n\nimport * as React from 'react'\n\nexport function useAsyncEffect(\n  effect: () => Promise<void | (() => Promise<void> | void)>,\n  deps: React.DependencyList = [],\n) {\n  const destroyRef = React.useRef<void | (() => Promise<void> | void) | undefined>(undefined)\n\n  const effectEvent = React.useEffectEvent(effect)\n\n  React.useEffect(() => {\n    const e = effectEvent()\n\n    async function execute() {\n      destroyRef.current = await e\n    }\n\n    execute()\n\n    return () => {\n      if (typeof destroyRef.current === 'function')\n        destroyRef.current()\n    }\n  // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, deps)\n}\n",
      "type": "registry:hook",
      "target": "hookas/use-async-effect.ts"
    }
  ],
  "type": "registry:hook"
}