Fix broken routing by unifying game state via Context API
This commit is contained in:
parent
6fc0820831
commit
82cae002f8
8 changed files with 53 additions and 20 deletions
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue