mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
ae1cad07dd
Closes: https://linear.app/vercel/issue/DOC-4539/version-upgrade-guides Redirects: https://github.com/vercel/front/pull/44175 Move version upgrade guides under `Guides`. Also creates a guides section under the Pages docs.
43 lines
892 B
Plaintext
43 lines
892 B
Plaintext
---
|
|
title: 'Multiple children were passed to `<Link>`'
|
|
---
|
|
|
|
## Why This Error Occurred
|
|
|
|
In your application code multiple children were passed to `next/link` but only one child is supported:
|
|
|
|
For example:
|
|
|
|
```jsx filename="example.js"
|
|
import Link from 'next/link'
|
|
|
|
export default function Home() {
|
|
return (
|
|
<Link href="/about">
|
|
<a>To About</a>
|
|
<a>Second To About</a>
|
|
</Link>
|
|
)
|
|
}
|
|
```
|
|
|
|
## Possible Ways to Fix It
|
|
|
|
Make sure only one child is used when using `<Link>`:
|
|
|
|
```jsx filename="example.js"
|
|
import Link from 'next/link'
|
|
|
|
export default function Home() {
|
|
return (
|
|
<Link href="/about">
|
|
<a>To About</a>
|
|
</Link>
|
|
)
|
|
}
|
|
```
|
|
|
|
> **Good to know**:
|
|
>
|
|
> - As on Next.js 13.0, `<Link>` no longer requires a child `<a>` tag. A [codemod](/docs/app/guides/upgrading/codemods#remove-a-tags-from-link-components) is provided to automatically update your codebase.
|