Spaces:
Runtime error
Runtime error
Download Frontend/src/components/auth/AuthToggleContext.jsx from jinksQspider/ExamCraftAI: direct link, hf CLI and curl.
- Browser
- Download file 753 Bytes
-
https://huggingface.co/spaces/jinksQspider/ExamCraftAI/resolve/main/Frontend/src/components/auth/AuthToggleContext.jsx
- Command line
-
hf download hf://spaces/jinksQspider/ExamCraftAI/Frontend/src/components/auth/AuthToggleContext.jsx
-
curl -L -o AuthToggleContext.jsx https://huggingface.co/spaces/jinksQspider/ExamCraftAI/resolve/main/Frontend/src/components/auth/AuthToggleContext.jsx
753 Bytes
| import React, { createContext, useContext, useState } from 'react'; | |
| const AuthToggleContext = createContext(); | |
| export const AuthToggleProvider = ({ children, initialMode = 'login' }) => { | |
| const [mode, setMode] = useState(initialMode); // 'login' or 'signup' | |
| const toggleMode = () => { | |
| setMode((prev) => (prev === 'login' ? 'signup' : 'login')); | |
| }; | |
| return ( | |
| <AuthToggleContext.Provider value={{ mode, setMode, toggleMode }}> | |
| {children} | |
| </AuthToggleContext.Provider> | |
| ); | |
| }; | |
| export const useAuthToggle = () => { | |
| const context = useContext(AuthToggleContext); | |
| if (!context) { | |
| throw new Error('useAuthToggle must be used within an AuthToggleProvider'); | |
| } | |
| return context; | |
| }; | |