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

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

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