Skip to content

perf: cut cascading re-renders from global state updates - #659

Open
Akatenvictor wants to merge 1 commit into
SmartDropLabs:mainfrom
Akatenvictor:perf/memoize-global-state-rerenders
Open

Akatenvictor wants to merge 1 commit into
SmartDropLabs:mainfrom
Akatenvictor:perf/memoize-global-state-rerenders

Conversation

@Akatenvictor

Copy link
Copy Markdown

Global context updates were re-rendering far more of the tree than needed:

  • useToast returned a fresh object every render and ErrorProvider wrapped it in a fresh { toast }, so every useErrorHandler() consumer re-rendered whenever ErrorProvider did. Both values are now memoized.
  • OwnConnectButtonContext shared one { count, update } object, so every page that only signals its CTA re-rendered on each count change. Count and the stable updater now live in separate contexts.
  • StellarWalletProvider gains a StellarWalletActionsContext exposing the stable connect/disconnect, read via the new useStellarWalletActions() hook; Navbar's WalletMenu uses it so it no longer re-renders when only the network changes.
  • AppShell chrome that does not depend on wallet state (Footer, SkipLink, RefetchIndicator, OfflineBanner, RpcUnreachableBanner) is wrapped in memo so wallet / own-CTA changes don't re-render it.
  • Navbar leaf components (Logo, NavLink, MoreMenu, StatPill, WalletMenu) are memoized, and WalletMenu's copy handler is a useCallback.
  • Farm page deposit handlers are useCallback so memoized FarmPoolRow children get stable props; the home page's animated AmbientBackground / GradientOrb and history's HistoryCard are memoized.

Closes #624
Closes #626
Closes #627
Closes #625

Global context updates were re-rendering far more of the tree than needed:

- useToast returned a fresh object every render and ErrorProvider wrapped
  it in a fresh `{ toast }`, so every useErrorHandler() consumer re-rendered
  whenever ErrorProvider did. Both values are now memoized.
- OwnConnectButtonContext shared one `{ count, update }` object, so every
  page that only signals its CTA re-rendered on each count change. Count
  and the stable updater now live in separate contexts.
- StellarWalletProvider gains a StellarWalletActionsContext exposing the
  stable connect/disconnect, read via the new useStellarWalletActions()
  hook; Navbar's WalletMenu uses it so it no longer re-renders when only
  the network changes.
- AppShell chrome that does not depend on wallet state (Footer, SkipLink,
  RefetchIndicator, OfflineBanner, RpcUnreachableBanner) is wrapped in
  memo so wallet / own-CTA changes don't re-render it.
- Navbar leaf components (Logo, NavLink, MoreMenu, StatPill, WalletMenu)
  are memoized, and WalletMenu's copy handler is a useCallback.
- Farm page deposit handlers are useCallback so memoized FarmPoolRow
  children get stable props; the home page's animated AmbientBackground /
  GradientOrb and history's HistoryCard are memoized.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@netlify

netlify Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

❌ Deploy Preview for smart-drop failed.

Name Link
🔨 Latest commit 4364f15
🔍 Latest deploy log https://app.netlify.com/projects/smart-drop/deploys/6ad326c8354ce9c4cb1dd48f

@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@Akatenvictor 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

@netlify

netlify Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

❌ Deploy Preview for spiffy-melomakarona-eb1e8a failed.

Name Link
🔨 Latest commit 4364f15
🔍 Latest deploy log https://app.netlify.com/projects/spiffy-melomakarona-eb1e8a/deploys/6ad326c815f717c676b3d5ee

This branch has not been deployed

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

Labels

None yet

Projects

None yet

1 participant