fix: faulty isMobile check

This commit is contained in:
2026-02-24 18:59:22 +01:00
parent bb2e4be41b
commit 244692d8f9
2 changed files with 5 additions and 17 deletions

View File

@@ -3,7 +3,7 @@
import { HabitIcon, TaskIcon } from '@/lib/constants'
import { Calendar, Coins, Gift, Home } from 'lucide-react'
import { useTranslations } from 'next-intl'
import { ElementType, useEffect, useState } from 'react'
import { ElementType } from 'react'
import NavDisplay from './NavDisplay'
export interface NavItemType {
@@ -14,13 +14,6 @@ export interface NavItemType {
export default function Navigation({ position }: { position: 'main' | 'mobile' }) {
const t = useTranslations('Navigation');
const [isMobile, setIsMobile] = useState(window.innerWidth < 1024);
useEffect(() => {
const handleResize = () => {setIsMobile(window.innerWidth < 1024); };
window.addEventListener("resize", handleResize);
return () => window.removeEventListener("resize", handleResize);
}, [setIsMobile]);
const currentNavItems: NavItemType[] = [
{ icon: Home, label: t('dashboard'), href: '/' },
@@ -31,10 +24,5 @@ export default function Navigation({ position }: { position: 'main' | 'mobile' }
{ icon: Coins, label: t('coins'), href: '/coins' },
]
if ((position === 'mobile' && isMobile) || (position === 'main' && !isMobile)) {
return <NavDisplay navItems={currentNavItems} isMobile={isMobile} />
}
else {
return <></>
}
return <NavDisplay navItems={currentNavItems} displayType={position} />
}