react-dom.development.js:86 Warning: validateDOMNesting(...):
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.
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.
Random Code Snippet Queries: React
- How do I link to an external URL in React?
- Get the ID from a URL in React and React Router
- Uncaught Error: useHref() may be used only in the context of a <Router> component
- We're unable to detect target browsers. react app
- Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead
- How to pass dynamic URL to Link in react ?
- Module Not Found: Can’T Resolve ‘Jquery’ In React
- Module not found: Error: Can't resolve 'prop-types'