|
@@ -1,4 +1,4 @@
|
|
|
-import React from "react";
|
|
|
+import React, { useEffect } from "react";
|
|
|
import {
|
|
|
PRE_GAME,
|
|
|
PRE_ROUND,
|
|
@@ -7,14 +7,13 @@ import {
|
|
|
POST_GAME,
|
|
|
ERROR,
|
|
|
} from "../domain/GameState";
|
|
|
-import PreGame from './screens/PreGame';
|
|
|
-import PreRound from './screens/PreRound';
|
|
|
+import { gameIdStore, gameStateStore } from "../domain/store";
|
|
|
+import PreGame from "./screens/PreGame";
|
|
|
+import PreRound from "./screens/PreRound";
|
|
|
import GamePanel from "./screens/GamePanel";
|
|
|
-import RoundSummary from './screens/RoundSummary';
|
|
|
+import RoundSummary from "./screens/RoundSummary";
|
|
|
import PlayerScores from "./screens/PlayerScores";
|
|
|
-import { gameIdStore, gameStateStore } from "../domain/store";
|
|
|
import useObservable from "../hooks/useObservable";
|
|
|
-import { useEffect } from "react";
|
|
|
|
|
|
const extractAndRemoveSearchParam = param => {
|
|
|
const u = new URL(window.location.href);
|
|
@@ -34,8 +33,6 @@ const componentMap = {
|
|
|
}
|
|
|
|
|
|
const Game = () => {
|
|
|
- const gameState = useObservable(gameStateStore);
|
|
|
-
|
|
|
useEffect(() => {
|
|
|
const joinCode = extractAndRemoveSearchParam("join");
|
|
|
if (joinCode) {
|
|
@@ -52,7 +49,7 @@ const Game = () => {
|
|
|
}
|
|
|
}, [])
|
|
|
|
|
|
- const Screen = componentMap[gameState];
|
|
|
+ const Screen = componentMap[useObservable(gameStateStore)];
|
|
|
|
|
|
return <Screen />
|
|
|
}
|