Added frontend folder structure in Ombase's branch

This commit is contained in:
K
2025-02-22 13:00:33 +05:30
parent 33b5c9ccc8
commit 75f31b5b93
60 changed files with 9080 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import React, { createContext, useMemo, useContext } from "react";
import { io } from "socket.io-client";
import { BACKEND_URL } from "../constants";
const SocketContext = createContext(null);
export const useSocket = () => {
const socket = useContext(SocketContext);
return socket;
};
export const SocketProvider = (props) => {
const socket = useMemo(
() =>
io(`${BACKEND_URL}`, {
withCredentials: true,
}),
[]
);
return (
<SocketContext.Provider value={socket}>
{props.children}
</SocketContext.Provider>
);
};