Added frontend folder structure.

This commit is contained in:
2025-02-22 12:54:00 +05:30
parent 8f13ac6d4b
commit 15593af2a9
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>
);
};