diff --git a/ui/src/multiplayer.tsx b/ui/src/multiplayer.tsx index d560a97..036cede 100644 --- a/ui/src/multiplayer.tsx +++ b/ui/src/multiplayer.tsx @@ -1,5 +1,5 @@ import * as React from "react"; -import {useState} from "react"; +import {useRef, useState} from "react"; import {createRoot} from "react-dom/client"; import {AISelection} from "./UI"; import {ClientToServerMessage, WSAPI, PartyInfo, ServerToClientMessage} from "./ws_api"; @@ -25,6 +25,8 @@ export function Menu(): React.JSX.Element { const [aiRandomness, setAIRandomness] = useState(6); const [proportionDictionary, setProportionDictionary] = useState(7); + + const gameAPI = useRef(null); const [game, setGame] = useState(null); const validSettings = roomName.length > 0 && !roomName.includes("/") && playerName.length > 0 && !playerName.includes("?") && !playerName.includes("&"); @@ -89,6 +91,7 @@ export function Menu(): React.JSX.Element { socket.close(); setSocket(null); setPartyInfo(null); + gameAPI.current = null; }}>Disconnect