aboutsummaryrefslogtreecommitdiff
path: root/components/socketContext.tsx
blob: 435f4a760325289de7b84b430f503089f3922963 (plain)
1
2
3
4
5
6
7
8
9
10
11
import { createContext, ReactNode } from 'react';
import { io as socket, Socket } from 'socket.io-client';

export var SocketContext = createContext<{ io?: Socket; }>({});
export function SocketContextWrapper(props: { children?: ReactNode; }) {
	var io = socket();

	return <SocketContext.Provider value={{ io }}>
		{props.children}
	</SocketContext.Provider>;
}