Skip to content

Dashboard SCREENS constant pre-mounts all 5 screens on load causing redundant data fetches #585

Description

@k-deejah

Problem

src/screens/Dashboard.tsx defines the screen map as a module-level constant:

const SCREENS: Record<NavSection, React.ReactNode> = {
  wallet: <WalletScreen />,
  account: <AccountScreen />,
  transactions: <TransactionsScreen />,
  soroban: <SorobanScreen />,
  network: <NetworkScreen />,
};

All five screen components are instantiated as JSX elements when this constant is evaluated — at module import time, before Dashboard even mounts. Every screen's useEffect hooks fire immediately: TransactionHistory fetches history, FeeEstimator fetches fees, ClaimableBalanceCard fetches claimable balances, and ContractEventFeed starts polling — all for screens the user has never visited.

Two more problems: (1) since all screens remain mounted permanently, navigating away from a screen does not unmount it — polling intervals and stale subscriptions accumulate for the session lifetime; (2) state (e.g. SorobanPanel's form inputs) persists across navigation trips, which may be surprising to users.

Solution

Replace the static constant with conditional rendering inside Dashboard, so only the active screen mounts:

<main className="flex-1 overflow-y-auto">
  <div className="max-w-[700px] mx-auto px-6 py-8 sm:px-10 sm:py-10">
    {active === "wallet"       && <WalletScreen />}
    {active === "account"      && <AccountScreen />}
    {active === "transactions" && <TransactionsScreen />}
    {active === "soroban"      && <SorobanScreen />}
    {active === "network"      && <NetworkScreen />}
  </div>
</main>

Acceptance Criteria

  • Only the currently active screen is mounted in the DOM at any time
  • Navigating away from a screen unmounts it and cleans up its effects and intervals
  • No data-fetching useEffect fires for screens the user has never visited
  • Switching between screens works correctly with no visible flicker
  • ContractEventFeed polling interval is cleaned up when SorobanScreen unmounts

Note for Contributors: If you're assigned to this issue, write a clear and detailed description for your pull request. Explain what was changed, why it was needed, how it was implemented, and include any relevant testing or screenshots where applicable.

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 programarchitectureCode structure, patterns, or design decisionsfrontendUI, component, or visual layer concernperformanceRendering speed, memory, or bundle size concerns

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions