mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 02:33:01 +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;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// safe version that returns null if outside provider
|
||||||
|
export function useSessionSafe(): SessionContextValue | null {
|
||||||
|
return useContext(SessionContext);
|
||||||
|
}
|
||||||
|
|
||||||
// for use inside RequireAuth
|
// for use inside RequireAuth
|
||||||
export function useAuthenticatedSession(): { user: UserRecord; setUser: (user: UserRecord) => void } {
|
export function useAuthenticatedSession(): { user: UserRecord; setUser: (user: UserRecord) => void } {
|
||||||
const { user, setUser } = useSession();
|
const { user, setUser } = useSession();
|
||||||
|
|||||||
Reference in New Issue
Block a user