Skip to content

[P1/arch] QueryFavorites.tsx 271 LOC with 8 useState hooks for transient UI state — should be a hook/store #340

Closed

Description

@EVWorth

Context

QueryFavorites.tsx:19-31 has eight useState declarations, all of local UI state: editingId, editValue, editDescId, editDescValue, search, expanded, showNewCategory, newCategoryName.

Problem

The editingId/editValue pair is essentially the same modal state with two fields duplicated. The editDescId/editDescValue is the same again. This is the same pattern that admin.md flagged for AdminPanel.tsx (F4) and UserManagement.tsx (F4). The component is below the 271 LOC threshold but the state structure is the same smell.

Files

  • src/components/favorites/QueryFavorites.tsx:19-31

Expected

A focused presentational layer; transient state pulled into a custom hook or view store.

Proposed fix

Scope M — extract transient edit state into a single useEditingState hook returning { editingId, editValue, startEdit, confirm, cancel, editDescId, editDescValue, startEditDesc, confirmDesc, cancelDesc }. Move the local search/expanded/showNewCategory/newCategoryName into a useFavoritesViewState hook or a dedicated favoritesViewStore (Zustand per ARCHITECTURE §3.7).

Acceptance

QueryFavorites.tsx drops to ≤ 200 LOC and has ≤ 3 useState calls; the extracted hooks each have their own test file.

Needs human verify

no

Activity

  1. added
    audit
    severity/p1
    kind/arch
    area/favorites
    on Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/favoritesauditkind/archseverity/p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions