aboutsummaryrefslogtreecommitdiff
path: root/components/socketContext.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'components/socketContext.tsx')
-rw-r--r--components/socketContext.tsx12
1 files changed, 12 insertions, 0 deletions
diff --git a/components/socketContext.tsx b/components/socketContext.tsx
new file mode 100644
index 0000000..f493d73
--- /dev/null
+++ b/components/socketContext.tsx
@@ -0,0 +1,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>
+}
+