diff --git a/app/components/Navigation.tsx b/app/components/Navigation.tsx index c2bae7f..e3cb315 100644 --- a/app/components/Navigation.tsx +++ b/app/components/Navigation.tsx @@ -5,7 +5,8 @@ import { Briefcase, Calendar, FileText, Home as HomeIcon, LifeBuoy, Lock, Map as MapIcon } from 'lucide-react'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; -import { useEffect, useRef } from 'react'; +import { useEffect, useLayoutEffect, useRef } from 'react'; +const useSafeLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect; const NavItem = ({ to, icon: Icon, label, className = "" }: { to: string, icon: any, label: string, className?: string }) => { const pathname = usePathname(); @@ -29,7 +30,7 @@ export const Navigation = () => { const pathname = usePathname(); const navRef = useRef(null); - useEffect(() => { + useSafeLayoutEffect(() => { window.scrollTo({ top: 0, behavior: 'instant' }); }, [pathname]);