DEV Community

00Rahmad00
00Rahmad00

Posted on

Missing "key" prop for element in iterator

Hey Guys, I am new in next.js, and i get an error while uploaded my next.js in Vercel and Netlify, Can anyone help me ?

`import Link from "next/link";
import { withRouter } from "next/router";

function Navbar({ router }) {
const navs = [
{ text: 'Home', href:'/'},
{ text: 'About', href:'/about'},
{ text: 'Portfolio', href:'/portfolio'},
{ text: 'Contact', href:'/contact'},
];

return (


Rahmad.

    <ul className="nav-links">
      {navs.map(nav => ( 
      <li><Link href={nav.href} className={`nav-item ${ router.pathname == nav.href ?  'active' : ''}`}>{nav.text}</Link></li> 
      ))}
    </ul>
  </div>
 </nav>

);
}

export default withRouter(Navbar);`

Top comments (1)