mirror of
https://github.com/hex248/sprint.git
synced 2026-02-07 18:23:03 +00:00
useSessionSafe - can be used outside of session provider
This commit is contained in:
@@ -21,6 +21,11 @@ export function useSession(): SessionContextValue {
|
||||
return context;
|
||||
}
|
||||
|
||||
// safe version that returns null if outside provider
|
||||
export function useSessionSafe(): SessionContextValue | null {
|
||||
return useContext(SessionContext);
|
||||
}
|
||||
|
||||
// for use inside RequireAuth
|
||||
export function useAuthenticatedSession(): { user: UserRecord; setUser: (user: UserRecord) => void } {
|
||||
const { user, setUser } = useSession();
|
||||
|
||||
Reference in New Issue
Block a user