Updated frontend

This commit is contained in:
sriram
2026-08-12 16:33:39 +05:30
parent d2ac832960
commit dae0b3e0fb
14 changed files with 297 additions and 164 deletions

20
src/context/useAuth.js Normal file
View File

@@ -0,0 +1,20 @@
import { createContext, useContext } from 'react';
/*
* The context object and its hook live here, apart from AuthContext.jsx.
*
* That split is what React Fast Refresh needs: a module that exports a
* component alongside non-component values cannot be hot-swapped, so every
* edit to the provider would remount the whole tree and drop the session you
* were testing with. AuthContext.jsx now exports only <AuthProvider>, and the
* hook everything imports lives in this plain module.
*/
export const AuthContext = createContext(null);
export function useAuth() {
const context = useContext(AuthContext);
if (!context) {
throw new Error('useAuth must be used within an AuthProvider');
}
return context;
}