Skip to content

Commit f23e79b

Browse files
fix: try get session again
1 parent 4ecdfc3 commit f23e79b

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

calc-frontend/src/App/RootLayout.tsx

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

77
import { authClient } from "../lib/auth-client";
88
import { Avatar, AvatarFallback, AvatarImage } from "../components/ui/avatar"
9-
import { useEffect, useState } from "react";
9+
import { useState } from "react";
1010

1111
function RootLayout() {
1212

1313
const oldSession = authClient.useSession();
1414

1515
const [session, setSession] = useState(oldSession)
1616

17-
useEffect(() => {
17+
// function to get the session
18+
const initializeSession = async() => {
19+
await authClient.getSession(); // getting session value
1820

19-
const initializeSession = async() => {
20-
await authClient.getSession(); // getting session value
21+
const newSession = authClient.useSession()
22+
23+
setSession(newSession);
24+
}
2125

22-
const newSession = authClient.useSession()
23-
24-
setSession(newSession);
25-
}
26-
27-
initializeSession()
28-
29-
},[])
26+
initializeSession()
3027

3128
return (
3229
<>

0 commit comments

Comments
 (0)