ok, so this website should be a modern private real estate, its a website where we will add high end properties, invitation only, so you need to create all the structure, backend as well so we can add and edit properties, create accounts
61cba86 verified Download src/context/AuthContext.jsx from matheusbezerra1/react-chakra-ui-magic-wand: direct link, hf CLI and curl.
- Browser
- Download file 745 Bytes
-
https://huggingface.co/spaces/matheusbezerra1/react-chakra-ui-magic-wand/resolve/main/src/context/AuthContext.jsx
- Command line
-
hf download hf://spaces/matheusbezerra1/react-chakra-ui-magic-wand/src/context/AuthContext.jsx
-
curl -L -o AuthContext.jsx https://huggingface.co/spaces/matheusbezerra1/react-chakra-ui-magic-wand/resolve/main/src/context/AuthContext.jsx
745 Bytes
| import { createContext, useContext, useEffect, useState } from 'react' | |
| import { auth } from '../firebase' | |
| import { onAuthStateChanged } from 'firebase/auth' | |
| const AuthContext = createContext() | |
| export function AuthProvider({ children }) { | |
| const [currentUser, setCurrentUser] = useState(null) | |
| const [loading, setLoading] = useState(true) | |
| useEffect(() => { | |
| const unsubscribe = onAuthStateChanged(auth, (user) => { | |
| setCurrentUser(user) | |
| setLoading(false) | |
| }) | |
| return unsubscribe | |
| }, []) | |
| const value = { | |
| currentUser, | |
| loading | |
| } | |
| return ( | |
| <AuthContext.Provider value={value}> | |
| {!loading && children} | |
| </AuthContext.Provider> | |
| ) | |
| } | |
| export function useAuth() { | |
| return useContext(AuthContext) | |
| } |