Skip to content

Commit

Permalink
Fix: wrong link error message (#28127)
Browse files Browse the repository at this point in the history
Fixes: #28126

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
  • Loading branch information
huozhi committed Aug 15, 2021
1 parent 971b17f commit 4cdb585
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/next/client/link.tsx
Expand Up @@ -237,7 +237,7 @@ function Link(props: React.PropsWithChildren<LinkProps>) {
throw new Error(
`Multiple children were passed to <Link> with \`href\` of \`${props.href}\` but only one child is supported https://nextjs.org/docs/messages/link-multiple-children` +
(typeof window !== 'undefined'
? "\nOpen your browser's console to view the Component stack trace."
? " \nOpen your browser's console to view the Component stack trace."
: '')
)
}
Expand Down
10 changes: 10 additions & 0 deletions test/acceptance/ReactRefreshLogBox.dev.test.js
Expand Up @@ -1130,6 +1130,16 @@ test('<Link> with multiple children', async () => {
expect(await session.getRedboxDescription()).toMatchInlineSnapshot(
`"Error: Multiple children were passed to <Link> with \`href\` of \`/\` but only one child is supported https://nextjs.org/docs/messages/link-multiple-children"`
)
expect(
await session.evaluate(
() =>
document
.querySelector('body > nextjs-portal')
.shadowRoot.querySelector(
'#nextjs__container_errors_desc a:nth-of-type(1)'
).href
)
).toMatch('https://nextjs.org/docs/messages/link-multiple-children')

await cleanup()
})
Expand Down

0 comments on commit 4cdb585

Please sign in to comment.