diff options
Diffstat (limited to 'src/state/session/index.tsx')
-rw-r--r-- | src/state/session/index.tsx | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/state/session/index.tsx b/src/state/session/index.tsx index adf6ccf6d..e45aa031f 100644 --- a/src/state/session/index.tsx +++ b/src/state/session/index.tsx @@ -23,16 +23,14 @@ import {readLabelers} from './agent-config' let __globalAgent: BskyAgent = PUBLIC_BSKY_AGENT -/** - * NOTE - * Never hold on to the object returned by this function. - * Call `getAgent()` at the time of invocation to ensure - * that you never have a stale agent. - */ -export function getAgent() { +function __getAgent() { return __globalAgent } +export function useAgent() { + return React.useMemo(() => ({getAgent: __getAgent}), []) +} + export type SessionAccount = persisted.PersistedAccount export type SessionState = { |