Next.js: Error: React.Children.only expected to receive a single React element child

This issue is due to the space between <Link> tag and <a> tag.

So change your code like,

            <Link href=""><a> Home </a></Link>
            <Link href=""><a> About </a></Link>

Reason for the change:

-> The <Link> can have only one child node and here the space between the link and a tag are considered as a child nodes.

-> So there are two child nodes (One is space and another is <a> tag) which is invalid and hence such error occurs.

Leave a Comment