Updated the Game.jsx
This commit is contained in:
parent
06569399eb
commit
9a6fc17a71
@ -12,7 +12,7 @@ export const Game = () => {
|
|||||||
const {groups, allGroups} = useContext(GroupContext);
|
const {groups, allGroups} = useContext(GroupContext);
|
||||||
|
|
||||||
const [currentState, setCurrentState] = useState("hint");
|
const [currentState, setCurrentState] = useState("hint");
|
||||||
|
const [currentRound, setCurrentRound] = useState(0);
|
||||||
|
|
||||||
const {musicEnabled} = useContext(MusicContext);
|
const {musicEnabled} = useContext(MusicContext);
|
||||||
|
|
||||||
@ -24,6 +24,10 @@ export const Game = () => {
|
|||||||
return () => clearTimeout(timeout);
|
return () => clearTimeout(timeout);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (currentState === "waiting") setCurrentRound(current => current + 1);
|
||||||
|
}, [currentState]);
|
||||||
|
|
||||||
if (groups.length === 0 && allGroups.length === 0)
|
if (groups.length === 0 && allGroups.length === 0)
|
||||||
return <Navigate to="/"/>;
|
return <Navigate to="/"/>;
|
||||||
|
|
||||||
@ -37,7 +41,7 @@ export const Game = () => {
|
|||||||
</h2>
|
</h2>
|
||||||
</>}
|
</>}
|
||||||
{currentState === "waiting" && <Waiting setState={setCurrentState}/>}
|
{currentState === "waiting" && <Waiting setState={setCurrentState}/>}
|
||||||
{currentState === "calculate" && <Calculate setState={setCurrentState}/>}
|
{currentState === "calculate" && <Calculate setState={setCurrentState} currentRound={currentRound}/>}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user