satnaing пре 2 година
родитељ
комит
d7c2f64a5c
2 измењених фајлова са 6 додато и 4 уклоњено
  1. 5 4
      src/components/nav.tsx
  2. 1 0
      src/components/top-nav.tsx

+ 5 - 4
src/components/nav.tsx

@@ -26,14 +26,15 @@ interface NavProps {
 
 export default function Nav({ links, isCollapsed }: NavProps) {
   const renderLink = ({ sub, ...rest }: SideLink) => {
+    const key = `${rest.title}-${rest.href}`
     if (isCollapsed && sub)
-      return <NavLinkIconDropdown {...rest} sub={sub} key={rest.href} />
+      return <NavLinkIconDropdown {...rest} sub={sub} key={key} />
 
-    if (isCollapsed) return <NavLinkIcon {...rest} key={rest.href} />
+    if (isCollapsed) return <NavLinkIcon {...rest} key={key} />
 
-    if (sub) return <NavLinkDropdown {...rest} sub={sub} key={rest.href} />
+    if (sub) return <NavLinkDropdown {...rest} sub={sub} key={key} />
 
-    return <NavLink {...rest} key={rest.href} />
+    return <NavLink {...rest} key={key} />
   }
   return (
     <div

+ 1 - 0
src/components/top-nav.tsx

@@ -17,6 +17,7 @@ export function TopNav({ className, links, ...props }: TopNavProps) {
     >
       {links.map(({ title, href, isActive }) => (
         <Link
+          key={`${title}-${href}`}
           to={href}
           className={`text-sm font-medium transition-colors hover:text-primary ${isActive ? '' : 'text-muted-foreground'}`}
         >