import {createContext, useMemo} from "react";
import {io} from "socket.io-client";

export const SocketContext = createContext()

export const SocketProvider = ({children}) => {
    const socket = useMemo(() => io(process.env.NEXT_PUBLIC_SERVER_SOCKET_URL, {
        autoConnect: false,
        auth: {
            token: ""
        }
    }), [])

    return <SocketContext.Provider value={{socket}}>{children}</SocketContext.Provider>
}