Uniswap / Uniswap/interface

Brand memoized args from React.useMemo

Open
#2,822 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

improvement performance refactor
Dominant language
TypeScript
Stars
5.5k
Forks
5.4k
PR merge metrics
No merged PRs in 30d

Description

Is your feature request related to a problem? Please describe.
Certain functions, like multicall, will only be performant when memoized. This can currently only be caught in code reviews (eg #2806).

Describe the solution you'd like
useMemo should be retyped to return a branded type, and useSingleCallResult should enforce (via typing) that passed arguments are memoized.

Describe alternatives you've considered
N/A

Additional context
Example tutorial of branding (like branding a cow, not like a company's brand): https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the React.useMemo usage and the useSingleCallResult hook, then inspect their existing TypeScript declarations and call sites. The work is done when memoized values carry a branded type and useSingleCallResult rejects non-memoized arguments through type checking.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.