mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-21 06:59:09 +00:00
socket bugfix
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
import { createContext, useContext, useEffect, useState } from 'react';
|
import { createContext, useContext, useEffect, useState } from 'react';
|
||||||
import io from 'socket.io-client';
|
import io from 'socket.io-client';
|
||||||
import { serverURL } from '../api/apiConstants';
|
|
||||||
import { NODE_PORT } from '../api/apiConstants';
|
import { NODE_PORT } from '../api/apiConstants';
|
||||||
|
|
||||||
export const SocketContext = createContext([[], () => {}]);
|
|
||||||
// get origin from URL
|
// get origin from URL
|
||||||
const serverURL = window.location.origin.replace(
|
const serverURL = window.location.origin.replace(
|
||||||
window.location.port,
|
window.location.port,
|
||||||
@@ -20,9 +18,9 @@ function SocketProvider(props) {
|
|||||||
const [socket, setSocket] = useState();
|
const [socket, setSocket] = useState();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const socket = io(serverURL, { transports: ['websocket'] });
|
const s = io(serverURL, { transports: ['websocket'] });
|
||||||
setSocket(socket);
|
setSocket(s);
|
||||||
return () => socket.disconnect();
|
return () => s.disconnect();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user