next.js: Next 13 does not throw exception when multi children are nested in LINK

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System: Platform: win32 Arch: x64 Version: Windows 10 Enterprise Binaries: Node: 16.17.0 npm: N/A Yarn: N/A pnpm: N/A Relevant packages: next: 13.0.6 eslint-config-next: 13.0.3 react: 18.2.0 react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

Routing (next/router, next/navigation, next/link)

Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

n/a

To Reproduce

            <Link
              href={`/loanApps/${Id}/upload`}
              className="inline-flex items-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:ring-offset-2 focus:ring-offset-gray-50 "
            >
     
                <CloudArrowUpIcon
                  className="-ml-1 mr-2 h-5 w-5 text-gray-400"
                  aria-hidden="true"
                />
                Upload
 
            </Link>

Describe the Bug

The browser or build did not catch the multiple children nested in the <LINK> tag. The previous version Next 12 did throw this error. Unexpected behavior can result if this error is not caught. In my case i had an issue with a websocket library called Signal-r. It was until i downgraded to 12, i was able to correct the issue, then i proceeded to upgrade back to 13. Now everything is gravy.

Please fix this issue so no one will have to go through my 12hr ordeal.

Expected Behavior

The browser should throw this error https://nextjs.org/docs/messages/link-multiple-children

Which browser are you using? (if relevant)

Edge

How are you deploying your application? (if relevant)

Azure

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

By looking at the example, i noticed that the jest example uses the package next/jest :

// nextjs/examples/with-jest/jest.config.js

const nextJest = require('next/jest')

const createJestConfig = nextJest({
  // Provide the path to your Next.js app to load next.config.js and .env files in your test environment
  dir: './',
})

I think it’s the package that have not been updated and still considering the Link component as the legacy one.

This produces an error in testing in next 13.0.6 but not in the console. Is there a jest configuration that also should be updated for next13 links?

<Link href={href} className={className}>
      {'hi'}
      {'hello'}
</Link>