forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add helpful error for link with multiple children (vercel#25657)
Makes sure a helpful error is shown for `<Link>` with multiple children ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. ## Documentation / Examples - [ ] Make sure the linting passes
- Loading branch information
1 parent
f817e60
commit 9890565
Showing
3 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# 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: | ||
|
||
```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>`: | ||
|
||
```js | ||
import Link from 'next/link' | ||
|
||
export default function Home() { | ||
return ( | ||
<Link href="/about"> | ||
<a>To About</a> | ||
</Link> | ||
) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters