Skip to content

useProfile constructs a new RegistryClient on every call instead of memoizing it #660

Description

@K1NGD4VID

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programfrontendNext.js Web Applicationgood first issueGood for newcomers

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions