diff --git a/packages/next/client/link.tsx b/packages/next/client/link.tsx index d6417116e1353..f98e72c79218f 100644 --- a/packages/next/client/link.tsx +++ b/packages/next/client/link.tsx @@ -275,7 +275,10 @@ const Link = React.forwardRef( children = childrenProp - if (legacyBehavior && typeof children === 'string') { + if ( + legacyBehavior && + (typeof children === 'string' || typeof children === 'number') + ) { children = {children} } diff --git a/test/integration/client-navigation/pages/link-number-child.js b/test/integration/client-navigation/pages/link-number-child.js new file mode 100644 index 0000000000000..58feab841e358 --- /dev/null +++ b/test/integration/client-navigation/pages/link-number-child.js @@ -0,0 +1,10 @@ +import React from 'react' +import Link from 'next/link' + +export default function Page() { + return ( +
+ Hello World. {1000} +
+ ) +} diff --git a/test/integration/client-navigation/test/index.test.js b/test/integration/client-navigation/test/index.test.js index 0b1646eb3e46e..5fd21c678bd0f 100644 --- a/test/integration/client-navigation/test/index.test.js +++ b/test/integration/client-navigation/test/index.test.js @@ -68,6 +68,12 @@ describe('Client Navigation', () => { ) }) + it('should not throw error when one number type child is provided', async () => { + const browser = await webdriver(context.appPort, '/link-number-child') + expect(await hasRedbox(browser)).toBe(false) + if (browser) await browser.close() + }) + it('should navigate back after reload', async () => { const browser = await webdriver(context.appPort, '/nav') await browser.elementByCss('#about-link').click()