fix: DisciplinesTab.tsx uses getState() during render — breaks React subscription #33

Closed
opened 2026-05-18 15:57:51 +02:00 by Anexim · 1 comment
Owner

Severity: Critical

File: src/components/game/tabs/DisciplinesTab.tsx (lines 51, 62, 72, 82, 196, 212)

Problem: The DisciplineCard component and the main DisciplinesTab component call useDisciplineStore().getState() directly during render. This reads the current state outside of React's subscription mechanism, meaning:

  1. The component won't re-render when the store changes
  2. Stale data will be displayed
  3. The UI will not reflect discipline state changes (XP, paused status, active attunement)

Impact: The Disciplines tab will show stale data and won't update when disciplines gain XP, get paused, or when the active attunement changes.

Fix: Use Zustand's selector pattern instead:

// Instead of: useDisciplineStore().getState().disciplines
// Use: useDisciplineStore(s => s.disciplines)

For the DisciplineCard component, pass needed values as props from the parent which subscribes to the store properly.

**Severity:** Critical **File:** `src/components/game/tabs/DisciplinesTab.tsx` (lines 51, 62, 72, 82, 196, 212) **Problem:** The `DisciplineCard` component and the main `DisciplinesTab` component call `useDisciplineStore().getState()` directly during render. This reads the current state outside of React's subscription mechanism, meaning: 1. The component won't re-render when the store changes 2. Stale data will be displayed 3. The UI will not reflect discipline state changes (XP, paused status, active attunement) **Impact:** The Disciplines tab will show stale data and won't update when disciplines gain XP, get paused, or when the active attunement changes. **Fix:** Use Zustand's selector pattern instead: ```ts // Instead of: useDisciplineStore().getState().disciplines // Use: useDisciplineStore(s => s.disciplines) ``` For the `DisciplineCard` component, pass needed values as props from the parent which subscribes to the store properly.
Anexim added the ai:todo label 2026-05-18 15:57:51 +02:00
n8n-gitea was assigned by Anexim 2026-05-18 15:57:51 +02:00
Author
Owner

Fixed: Refactored DisciplinesTab.tsx to pass discipline state and toggle handler as props to DisciplineCard, eliminating getState() calls during render. The parent component now subscribes to the store via selectors and passes data down.

Fixed: Refactored DisciplinesTab.tsx to pass discipline state and toggle handler as props to DisciplineCard, eliminating getState() calls during render. The parent component now subscribes to the store via selectors and passes data down.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#33