Category: Performance
Repository location: apps/web/hooks/useProfile.ts (lines ~71, 91, 112)
Problem
useProfile does const client = new RegistryClient(registryContractID); independently in three separate places (once per query/mutation), re-constructing the SDK client object on every refetch or mutation call — including on each interval-based refetch. usePool.ts already establishes the correct pattern: const poolClient = useMemo(() => new PoolClient(poolContractID), []);.
Evidence
useProfile.ts has three separate new RegistryClient(registryContractID) call sites; usePool.ts line ~32 memoizes its client with useMemo.
Suggested implementation
Memoize a single RegistryClient instance the same way usePool does, and reuse it across all three call sites in useProfile.
Acceptance criteria
useProfile constructs exactly one RegistryClient instance per mount, verified by a test that spies on the RegistryClient constructor.
Difficulty: Easy
Expected impact: Removes avoidable object churn on a hook that polls/refetches regularly.
Filed as part of the second repository-wide audit (deeper refinements following the first cleanup pass).
Category: Performance
Repository location: apps/web/hooks/useProfile.ts (lines ~71, 91, 112)
Problem
useProfiledoesconst client = new RegistryClient(registryContractID);independently in three separate places (once per query/mutation), re-constructing the SDK client object on every refetch or mutation call — including on each interval-based refetch.usePool.tsalready establishes the correct pattern:const poolClient = useMemo(() => new PoolClient(poolContractID), []);.Evidence
useProfile.tshas three separatenew RegistryClient(registryContractID)call sites;usePool.tsline ~32 memoizes its client withuseMemo.Suggested implementation
Memoize a single
RegistryClientinstance the same wayusePooldoes, and reuse it across all three call sites inuseProfile.Acceptance criteria
useProfileconstructs exactly oneRegistryClientinstance per mount, verified by a test that spies on theRegistryClientconstructor.Difficulty: Easy
Expected impact: Removes avoidable object churn on a hook that polls/refetches regularly.
Filed as part of the second repository-wide audit (deeper refinements following the first cleanup pass).