react-dom.development.js:86 Warning: validateDOMNesting(...):

Created at 05-Nov-2022 , By samar

react-dom.development.js:86 Warning: validateDOMNesting(...):

Through the use of the programming language, we will work together to solve the "react-dom.development.js:86 Warning: validateDOMNesting(...):" puzzle in this lesson.

You are getting error react-dom.development.js:86 Warning: validateDOMNesting(...): <a> cannot appear as a descendant of <a>. Because you have a invalid DOM structure in your react app. You are using an anchor tag (<a>) inside another anchor tag.

You can see the DOM structure on click of the element tab after clicking on inspect element in your browser. You can inspect HTML elements in your google chrome browser by clicking on the right button of the mouse or by using CTRL + SHIFT + I button.

Your HTML DOM structure should not look like below.

<a><a></a></a>
<a class="nav-link active" aria-current="page" href="/">Home
 <a class="nav-link active" aria-current="page" href="/">Home</a>
</a>

You can not use an anchor tag inside another anchor tag.

Sample code with Error

<Link className="nav-link"  to="/menu">Menu
    <Link className="nav-link" to="/submenu">Sub Menu</Link>
</Link>

Sample code without Error

<Link className="nav-link"  to="/menu">Menu </Link>
<Link className="nav-link" to="/submenu">Sub Menu</Link>

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.