From a7e3433ecc0b9b069da5860b43c74665eb9b0ac8 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 25 Apr 2024 14:07:57 -0500 Subject: [PATCH] Memoize getAgent method --- src/state/session/index.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/state/session/index.tsx b/src/state/session/index.tsx index 6a04a8a0ff..8ca347ae41 100644 --- a/src/state/session/index.tsx +++ b/src/state/session/index.tsx @@ -24,11 +24,14 @@ import {readLabelers} from './agent-config' let __globalAgent: BskyAgent = PUBLIC_BSKY_AGENT export function useAgent() { - return { - getAgent() { - return __globalAgent - }, - } + return React.useMemo( + () => ({ + getAgent() { + return __globalAgent + }, + }), + [], + ) } export type SessionAccount = persisted.PersistedAccount