Skip to content

Commit a398cbf

Browse files
Merge pull request #197 from Speedrunyourknowledge/develop
fix: get session
2 parents 0285cff + 4ecdfc3 commit a398cbf

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

calc-frontend/src/App/RootLayout.tsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,27 @@ import CalcLogo from "../components/CalcLogo"
66

77
import { authClient } from "../lib/auth-client";
88
import { Avatar, AvatarFallback, AvatarImage } from "../components/ui/avatar"
9-
10-
await authClient.getSession(); // get session
9+
import { useEffect, useState } from "react";
1110

1211
function RootLayout() {
13-
const session = authClient.useSession();
12+
13+
const oldSession = authClient.useSession();
14+
15+
const [session, setSession] = useState(oldSession)
16+
17+
useEffect(() => {
18+
19+
const initializeSession = async() => {
20+
await authClient.getSession(); // getting session value
21+
22+
const newSession = authClient.useSession()
23+
24+
setSession(newSession);
25+
}
26+
27+
initializeSession()
28+
29+
},[])
1430

1531
return (
1632
<>

0 commit comments

Comments
 (0)