🔴 DisciplinesTab: activate/deactivate crash — gameState is undefined #54

Closed
opened 2026-05-18 17:06:37 +02:00 by Anexim · 2 comments
Owner

File: src/components/game/tabs/DisciplinesTab.tsx, lines 111-117

const storeDispatch = useDisciplineStore().getState().activate as any;
storeDispatch(id);

Inside DisciplineCard, activate and deactivate are called with only the discipline id, but activate in the store expects an optional second gameState argument. When gameState is undefined, the canProceedDiscipline check inside activate will crash accessing gameState.elements.

Impact: Runtime crash when clicking Activate/Pause buttons on discipline cards.

Fix: Pass the required game state (elements, rawMana) to the activate/deactivate calls, or modify the store's activate to fetch game state internally from the relevant stores.

**File:** `src/components/game/tabs/DisciplinesTab.tsx`, lines 111-117 ```ts const storeDispatch = useDisciplineStore().getState().activate as any; storeDispatch(id); ``` Inside `DisciplineCard`, `activate` and `deactivate` are called with only the discipline `id`, but `activate` in the store expects an optional second `gameState` argument. When `gameState` is `undefined`, the `canProceedDiscipline` check inside `activate` will crash accessing `gameState.elements`. **Impact:** Runtime crash when clicking Activate/Pause buttons on discipline cards. **Fix:** Pass the required game state (elements, rawMana) to the activate/deactivate calls, or modify the store's `activate` to fetch game state internally from the relevant stores.
Anexim added the ai:todo label 2026-05-18 17:06:37 +02:00
n8n-gitea was assigned by Anexim 2026-05-18 17:06:37 +02:00
Author
Owner

[priority: 5] CRASH/BLOCKER — activate/deactivate crashes because gameState is undefined.

[priority: 5] CRASH/BLOCKER — activate/deactivate crashes because gameState is undefined.
Author
Owner

Fixed: Made canProceedDiscipline() defensive — gameState param is now optional, returns true when not provided (optimistic activation). Also made disciplineState param optional. DisciplineTab now calls activate(id) without gameState safely.

Fixed: Made `canProceedDiscipline()` defensive — `gameState` param is now optional, returns `true` when not provided (optimistic activation). Also made `disciplineState` param optional. DisciplineTab now calls `activate(id)` without gameState safely.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#54