Skip to content

perf: memoize dashboard streams table and activity list to prevent unnecessary re-renders - #1361

Merged
K1NGD4VID merged 2 commits into
LabsCrypt:mainfrom
Horlarmmy:fix/memoize-dashboard-renders
Aug 30, 2026
Merged

perf: memoize dashboard streams table and activity list to prevent unnecessary re-renders#1361
K1NGD4VID merged 2 commits into
LabsCrypt:mainfrom
Horlarmmy:fix/memoize-dashboard-renders

Conversation

@Horlarmmy

Copy link
Copy Markdown
Contributor

Problem

renderStreams and renderRecentActivity in dashboard-view.tsx were plain functions invoked on every render of DashboardView. Any state change anywhere in this large component (e.g. typing into the template-name input) re-executed the full streams-table and activity-list JSX construction, causing unnecessary re-renders of heavy list components.

Solution

Extracted both render functions into standalone memoized components and stabilized their callback props with useCallback:

  1. StreamsTable — Wrapped with React.memo, receives snapshot, onTopUp, onCancel, onShowDetails
  2. RecentActivityList — Wrapped with React.memo, receives snapshot, onCreateStream
  3. Callback stabilization — Added useCallback hooks for handleTopUp, handleCancel, handleShowDetails, and handleShowWizard to prevent child re-renders from callback identity changes

Changes

  • frontend/src/components/dashboard/dashboard-view.tsx
    • Converted renderStreams (lines 369-451) → StreamsTable component with React.memo
    • Converted renderRecentActivity (lines 453-504) → RecentActivityList component with React.memo
    • Added useCallback hooks for 4 callback props in DashboardView
    • Updated 4 call sites from function calls to JSX component usage

Impact

  • Streams table and activity list no longer re-render when unrelated local state changes (e.g. templateNameInput, editingTemplateId, selectedTemplateId)
  • Reduces wasted render work on the highest-traffic page, especially with larger stream/activity lists
  • React DevTools profiler: these components now skip re-renders when snapshot and callbacks remain stable

Testing

All existing tests pass (286/286 across 32 test files). Lint and typecheck clean.

Closes #1243

@K1NGD4VID
K1NGD4VID merged commit e01bcfb into LabsCrypt:main Aug 30, 2026
11 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

Development

Successfully merging this pull request may close these issues.

[Audit] Large table/activity render functions re-execute on every unrelated state change

2 participants