Skip to content

Commit 9c1d4e5

Browse files
committed
feat: update useUserSession hook to handle undefined session state
1 parent db92e12 commit 9c1d4e5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/components/d-user/DUser.session.hook.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import React from "react";
22
import type {UserSession} from "@code0-tech/sagittarius-graphql-types";
33

44
export const useUserSession = () => {
5-
const [session, setSession] = React.useState<UserSession | null>(null)
5+
const [session, setSession] = React.useState<UserSession | undefined | null>(undefined)
66

77
React.useEffect(() => {
88
const userSession = JSON.parse(localStorage.getItem("ide_code-zero_session")!!) as UserSession
99
if (userSession && userSession.token) setSession(userSession)
10+
else setSession(null)
1011
}, [])
1112

1213
return session

0 commit comments

Comments
 (0)