You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have problem with client session, I need to reload manually reload page to get session, on server its okej.
After logging in, client component is not getting session data, only when reload it gets data.
NavBar1.tsx:
export async function Navbar1() {
const session = await auth()
console.log(JSON.stringify(session) + " from server")
return (
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have problem with client session, I need to reload manually reload page to get session, on server its okej.
After logging in, client component is not getting session data, only when reload it gets data.
NavBar1.tsx:
export async function Navbar1() {
const session = await auth()
console.log(JSON.stringify(session) + " from server")
return (
)
}
NavRoutes.tsx:
export function NavRoutes() {
const currentPath = usePathname();
const {data, update} = useSession();
const isActive = (path: string) => {
return currentPath === path;
}
console.log(data)
return (
<Link href="/o-nama" className={isActive("/o-nama") ? "text-red-600" : "hover:text-red-600"}>O NAMA
<Link href="/kontakt" className={isActive("/kontakt") ? "text-red-600" : "hover:text-red-600"}>KONTAKT
<Link href="/prodavnica" className={isActive("/prodavnica") ? "text-red-600" : "hover:text-red-600"}>PRODAVNICA
{!!data ? <><Link href="/moj-nalog" className={isActive("/moj-nalog") ? "text-red-600" : "hover:text-red-600"}>MOJ NALOG
<Link href="/" className={"hover:text-red-600"} onClick={() => { signOut(); }}>ODJAVI SE </> : <Link href="/auth" className={isActive("/auth") ? "text-red-600" : "hover:text-red-600"}>PRIJAVI SE}
)
}
Beta Was this translation helpful? Give feedback.
All reactions