Issue
How does one add a css class to a Link component in Next.js?
<Link
className="app-subnav__link"
href="/globalSettings"
>
Settings overview
</Link>
It doesn't like the above! ES Link is throwing an error:
Solution
Try this (available in NextJS v13):
<Link href="/globalSettings" className="app-subnav__link">
Settings Overview
</Link>
Reference: https://nextjs.org/docs/api-reference/next/link
Update: in NextJS v13 The next/link child can no longer be . Add the legacyBehavior prop to use the legacy behavior or remove the to upgrade. A codemod is available to automatically upgrade your code.
Answered By - Alireza Amini
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.