summaryrefslogtreecommitdiff
path: root/client/src/Mancala/Mancala.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/Mancala/Mancala.tsx')
-rw-r--r--client/src/Mancala/Mancala.tsx13
1 files changed, 10 insertions, 3 deletions
diff --git a/client/src/Mancala/Mancala.tsx b/client/src/Mancala/Mancala.tsx
index 1c712c8..509410b 100644
--- a/client/src/Mancala/Mancala.tsx
+++ b/client/src/Mancala/Mancala.tsx
@@ -9,7 +9,7 @@ import "./Mancala.css";
* users to enter two player names and start a new game.
* If there's an active game this component holds the game state. This game state can be passed as a prop
* to child components as needed.
- *
+ *
* Child components can modify the game state by calling the setGameState (which they recieve as prop.)
*/
export function Mancala() {
@@ -20,9 +20,16 @@ export function Mancala() {
// To check if code you added also follows the rules of hooks, run "npm run lint" in the command line
const [ gameState, setGameState ] = useState<GameState | undefined>(undefined);
+ if (localStorage.getItem("state") !== null) {
+ var state = localStorage.getItem("state");
+ const gameState = JSON.parse(state as string);
+ return <Play gameState={gameState} setGameState={setGameState} />
+ }
+
if (!gameState) {
- return <StartGame setGameState={setGameState} />
+ return <StartGame gameState={gameState} setGameState={setGameState} />
}
+
return <Play gameState={gameState} setGameState={setGameState} />
-} \ No newline at end of file
+}