Fix broken routing by unifying game state via Context API

This commit is contained in:
10x Developer 2026-05-08 21:35:14 +02:00
parent 6fc0820831
commit 82cae002f8
8 changed files with 53 additions and 20 deletions

View file

@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { Player, GameState } from '../../types';
import useGameState from '../../hooks/useGameState';
import { useGameStateContext } from '../../context/GameStateContext';
const SetupScreen: React.FC = () => {
const {
@ -9,7 +9,7 @@ const SetupScreen: React.FC = () => {
updateCardValues,
addPlayer,
startNewGame
} = useGameState();
} = useGameStateContext();
const [newPlayerName, setNewPlayerName] = useState('');
@ -147,7 +147,7 @@ const SetupScreen: React.FC = () => {
<button onClick={startGame} disabled={gameState.players.length < 2}>
Start Game
</button>
<button onClick={() => window.location.hash = '#history'} className="secondary">
<button onClick={() => gameState.setCurrentScreen('history')} className="secondary">
View History
</button>
</div>