CFE-5 initialize socket provider
This commit is contained in:
14
src/lib/app/contexts/socket.jsx
Normal file
14
src/lib/app/contexts/socket.jsx
Normal file
@@ -0,0 +1,14 @@
|
||||
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>
|
||||
}
|
||||
Reference in New Issue
Block a user