From f3ce5681c140fa5a00295adf5476771e67f8be58 Mon Sep 17 00:00:00 2001 From: cv <34649812+cpvalente@users.noreply.github.com> Date: Fri, 23 Apr 2021 15:02:28 +0200 Subject: [PATCH] socket bugfix --- client/src/app/context/socketContext.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/client/src/app/context/socketContext.js b/client/src/app/context/socketContext.js index 89cde317d..6767173ed 100644 --- a/client/src/app/context/socketContext.js +++ b/client/src/app/context/socketContext.js @@ -1,9 +1,7 @@ import { createContext, useContext, useEffect, useState } from 'react'; import io from 'socket.io-client'; -import { serverURL } from '../api/apiConstants'; import { NODE_PORT } from '../api/apiConstants'; -export const SocketContext = createContext([[], () => {}]); // get origin from URL const serverURL = window.location.origin.replace( window.location.port, @@ -20,9 +18,9 @@ function SocketProvider(props) { const [socket, setSocket] = useState(); useEffect(() => { - const socket = io(serverURL, { transports: ['websocket'] }); - setSocket(socket); - return () => socket.disconnect(); + const s = io(serverURL, { transports: ['websocket'] }); + setSocket(s); + return () => s.disconnect(); }, []); return (