SocketContext.ts 327 Bytes
import React from "react";
import { io } from "socket.io-client";

export const socket = io(`http://${window.location.hostname}:3000/`);
const SocketContext = React.createContext(socket);

export const SocketProvider = SocketContext.Provider;
export const SocketConsumer = SocketContext.Consumer;
export default SocketContext;