Skip to content

perf(wallet): memoize wallet connection display computations - #1281

Merged
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
Gracora:feat/issue-1170-memoize-wallet-connection
Oct 15, 2026
Merged

nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
Gracora:feat/issue-1170-memoize-wallet-connection

Conversation

@Gracora

@Gracora Gracora commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Memoizes the derived display values computed inside the WalletConnection connected view so the truncated address and formatted balance are only recalculated when the underlying address or balance actually changes. This removes repeated string formatting from renders caused by unrelated wallet or chain state updates.

Problem

WalletConnectedView recomputed ormatAddress(address) and ormatBalanceForDisplay(balance) on every render. Because the view re-renders on wallet store and chain awareness updates, those formatting helpers ran far more often than their inputs changed, adding avoidable work to a component that sits in the page header.

Changes Made

  • Updated src/components/WalletConnectedView.tsx to derive �ddressDisplay and �alanceText in a single useMemo keyed on [address, balance].
  • Replaced the direct ormatAddress(address) call in the JSX with the memoized �ddressDisplay value.

Implementation Details

Both formatting helpers are now invoked together inside one memoization block, so a render triggered by an unrelated store field keeps the previous strings instead of reformatting them. The existing useCallback for the disconnect handler and the React.memo wrapper on the view were left unchanged.

Closes #1170

Closes #1169

Closes #1168

Closes #1167

@drips-wave

drips-wave Bot commented Oct 15, 2026

Copy link
Copy Markdown

@Gracora Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@nanaf6203-bit nanaf6203-bit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nanaf6203-bit
nanaf6203-bit merged commit dac8d70 into MettaChain:main Oct 15, 2026
2 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants