[HIGH] Memoize filteredSubscriptions in App.tsx - prevent recomputation on every keystroke #33

Closed
opened 2026-06-09 00:03:13 +00:00 by Mark · 0 comments
Owner

Location: src/App.tsx:364-368

Problem: filteredSubscriptions is recomputed on every render by scanning the full subscriptions array with 2x .toLowerCase() per item. Combined with uncontrolled AuthContext re-renders, this fires on every state change.

Impact: Linear scan over full array on every keystroke + every parent state change.

Fix:

const filteredSubscriptions = useMemo(
  () => subscriptions.filter((sub) =>
    sub.name.toLowerCase().includes(searchQuery.toLowerCase()) ||
    sub.category.toLowerCase().includes(searchQuery.toLowerCase())
  ),
  [searchQuery, subscriptions]
);

Effort: ~30 mins

**Location:** `src/App.tsx:364-368` **Problem:** `filteredSubscriptions` is recomputed on every render by scanning the full subscriptions array with 2x `.toLowerCase()` per item. Combined with uncontrolled AuthContext re-renders, this fires on every state change. **Impact:** Linear scan over full array on every keystroke + every parent state change. **Fix:** ```ts const filteredSubscriptions = useMemo( () => subscriptions.filter((sub) => sub.name.toLowerCase().includes(searchQuery.toLowerCase()) || sub.category.toLowerCase().includes(searchQuery.toLowerCase()) ), [searchQuery, subscriptions] ); ``` **Effort:** ~30 mins
Mark 2026-06-09 00:03:13 +00:00
  • closed this issue
  • added the
    bug
    label
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/subvault#33
No description provided.