rsnext/errors/link-no-children.mdx
Delba de Oliveira 44d1a1cb15
docs: Migrate error messages to MDX and App Router. (#52038)
This PR is part of a larger effort to migrate error messages to MDX and
use App Router: https://github.com/vercel/front/pull/23459
2023-07-05 06:11:16 -07:00

43 lines
751 B
Text

---
title: 'No children were passed to `<Link>`'
---
## Why This Error Occurred
In your application code, `next/link` was used without passing a child:
For example:
```jsx filename="pages/index.js"
import Link from 'next/link'
export default function Home() {
return (
<>
<Link href="/about" legacyBehavior></Link>
// or
<Link href="/about" legacyBehavior />
</>
)
}
```
## Possible Ways to Fix It
Make sure one child is used when using `<Link>`:
```jsx filename="pages/index.js"
import Link from 'next/link'
export default function Home() {
return (
<>
<Link href="/about">To About</Link>
// or
<Link href="/about" legacyBehavior>
<a>To About</a>
</Link>
</>
)
}
```