From 856a9b97bf2c6840b01443b7efb1be6cea8e663e Mon Sep 17 00:00:00 2001 From: Miqdad Date: Thu, 18 Sep 2025 10:29:10 +0700 Subject: fix hydration issue --- app/lib/camera/component/hedear.tsx | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/app/lib/camera/component/hedear.tsx b/app/lib/camera/component/hedear.tsx index 2a8bfc6..81f5d01 100644 --- a/app/lib/camera/component/hedear.tsx +++ b/app/lib/camera/component/hedear.tsx @@ -1,36 +1,53 @@ // components/Header.tsx +"use client"; + import Image from "next/image"; import { deleteAuth, getAuth } from "../../api/auth"; import { Button } from "@mui/material"; import { useRouter } from "next/navigation"; +import { useEffect, useState } from "react"; export default function Header() { - const auth = getAuth(); - const route = useRouter(); + const router = useRouter(); + const [mounted, setMounted] = useState(false); + const [auth, setAuth] = useState(null); + + useEffect(() => { + setMounted(true); + try { + setAuth(getAuth()); + } catch { + setAuth(null); + } + }, []); - const handleSigOut = () => { + const handleSignOut = () => { deleteAuth(); - route.push('/login'); + router.push("/login"); }; + return ( ); -- cgit v1.2.3