Nextjs is link not working in single line
See original GitHub issueimport Link from 'next/link';
const Index = () => {
return (
<div>
<ul>
<li>
<Link href="/"> <a>Home</a> </Link>
</li>
</ul>
<h1>Hellow Next.js</h1>
</div>
)
}
export default Index;
First i declared <a> </a>
tag in one line into <Link></Link>
but its through me Error
React.Children.only expected to receive a single React element child.
After i added a line break like this
<Link href="/">
<a>Home</a>
</Link>
it works fine. whats the problem?
Thanks 😃
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Nextjs is link not working in single line · Issue #8035 - GitHub
Yes, the space is the thing to blame here. It's not to do with Next.js and is related to how jsx (React markup)...
Read more ><Link> does not work as expected in NextJS - Stack Overflow
I tried adding an <a> tag under my Link and it worked. I am coming from react-router, and felt that just adding the...
Read more >next/link | Next.js
Enable client-side transitions between routes with the built-in Link component.
Read more >Link Component - Navigate Between Pages | Learn Next.js
In Next.js, you can use the Link Component next/link to link between pages in your application. <Link> allows you to do client-side navigation...
Read more >no-html-link-for-pages - Next.js
The Link component is required in order to enable client-side route transitions between pages and provide a single-page app experience.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t think we can make changes here, also the issue doesn’t follow / ignores the issue template.
Yes, the space is the thing to blame here. It’s not to do with Next.js and is related to how jsx (React markup) is transpiled to normal JS. https://stackoverflow.com/a/32690647