From 4ef2f2a7adda287dadbf62d9d15cdf14aa6a3eee Mon Sep 17 00:00:00 2001 From: Pouria Delfanazari Date: Tue, 12 Dec 2023 19:22:47 -0800 Subject: [PATCH] Fix dependency issue --- src/lib/hooks/bsky/useAgent.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/lib/hooks/bsky/useAgent.tsx b/src/lib/hooks/bsky/useAgent.tsx index a255508e..8f4fff4a 100644 --- a/src/lib/hooks/bsky/useAgent.tsx +++ b/src/lib/hooks/bsky/useAgent.tsx @@ -4,8 +4,7 @@ import { useRouter } from "next/navigation"; import { createAgent } from "@/lib/api/bsky/agent"; export default function useAgent() { - const at = createAgent(); - const [agent, setAgent] = useState(at); + const [agent, setAgent] = useState(createAgent()); const { data: session, status } = useSession(); const router = useRouter(); @@ -18,12 +17,11 @@ export default function useAgent() { const getAgent = async () => { const bskySession = session.user.bskySession; - at.session = bskySession; - setAgent(at); + agent.session = bskySession; }; getAgent(); - }, [at, router, session?.user.bskySession, status]); + }, [agent, router, session?.user.bskySession, status]); return agent; -} +} \ No newline at end of file