aboutsummaryrefslogtreecommitdiff
path: root/components/socketContext.tsx
blob: f493d73badc908e6e148aa694d3aba931c008801 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
import { ReactNode, createContext } 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>
}