File size: 391 Bytes
2bd3674
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import {createContext, useContext} from 'react';
import {Socket} from 'socket.io-client';

type SocketObject = {
  socket: Socket | null;
  clientID: string | null;
  connected: boolean;
};

export const SocketContext = createContext<SocketObject>({
  socket: null,
  clientID: null,
  connected: false,
});

export function useSocket(): SocketObject {
  return useContext(SocketContext);
}