Unverified Commit 4cdb5859 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Fix: wrong link error message (#28127)



Fixes: #28126

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
parent 971b17f1
...@@ -237,7 +237,7 @@ function Link(props: React.PropsWithChildren<LinkProps>) { ...@@ -237,7 +237,7 @@ function Link(props: React.PropsWithChildren<LinkProps>) {
throw new Error( 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` + `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' (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."
: '') : '')
) )
} }
......
...@@ -1130,6 +1130,16 @@ test('<Link> with multiple children', async () => { ...@@ -1130,6 +1130,16 @@ test('<Link> with multiple children', async () => {
expect(await session.getRedboxDescription()).toMatchInlineSnapshot( 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"` `"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() await cleanup()
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment