bradtraversy / next-crash-course

Project from my Next.js crash course on YouTube
429 stars 328 forks source link

ArticleItem requires legacyBehavior prop with <a> children #7

Open desrtCodr opened 1 year ago

desrtCodr commented 1 year ago

I believe the ArticleItem.js component needs to be updated to include the "legacyBehavior" prop due to the fact that <a> tags are used as children. Or needs to be refactored to meet the new Link requirements.

possible solution:

import Link from 'next/link'
import articleStyles from '../styles/Article.module.css'

const ArticleItem = ({ article }) => {
  return (
    <Link legacyBehavior href={`/article/${article.id}`}>
      <a className={articleStyles.card}>
        <h3>{article.title} &rarr;</h3>
        <p>{article.body}</p>
      </a>
    </Link>
  )
}

export default ArticleItem
RamiZuhairi commented 1 year ago

great one thank you , I have solved that by putting div tag instead of a tag

Hitendra27 commented 1 year ago

Thank you guys. solved it too.