Commit d42389dc authored by Chunchi Che's avatar Chunchi Che Committed by GitHub

Merge pull request #2 from DarkNeos/dev

fix websocket connect twice
parents e200c465 a9638d31
......@@ -8,7 +8,9 @@ export default function JoinHome(props: { addr: string }) {
const [isJoined, setJoined] = useState(false);
useEffect(() => {
ws.current = new WebSocket(props.addr);
if (!ws.current) {
ws.current = new WebSocket(props.addr);
}
ws.current.onopen = () => {
console.log("websocket open");
......@@ -40,8 +42,6 @@ export default function JoinHome(props: { addr: string }) {
};
let handleButtonOnClick = () => {
console.log("buttom clicked");
if (!ws.current) {
console.error("websocket not connected");
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment