Refactor/ts sockets (#210)

* refactor(ts): create socket subscription service
* refactor(ts-sockets): useSubscription hook
* refactor(ts-sockets): extract colour selection to utility
This commit is contained in:
Carlos Valente
2022-10-09 19:09:47 +02:00
committed by GitHub
parent f119fb4529
commit cd0577bf99
26 changed files with 346 additions and 254 deletions
+1 -2
View File
@@ -1,4 +1,3 @@
// @ts-nocheck
import { createContext, ReactNode, useContext, useEffect, useState } from 'react';
import { serverURL } from 'common/api/apiConstants';
import io, { Socket } from 'socket.io-client';
@@ -26,7 +25,7 @@ export const useSocket = () => {
};
function SocketProvider({ children }: SocketProviderProps) {
const [socket, setSocket] = useState(null);
const [socket, setSocket] = useState<Socket | null>(null);
useEffect(() => {
const socketInstance = io(serverURL, { transports: ["websocket"] });