question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

validateDOMNesting warns when optional tags are missing

See original GitHub issue

According to the HTML 5 spec, certain tags are optional in specific circumstances because their presence is implied. However, I’m getting warnings for these cases.

I imagine this complexity is not something worth accounting for within validateDOMNesting, but I wanted to call it out just the same.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
joshdmillercommented, Jul 22, 2015

@spicyj Thanks for the clarification - that’s helpful. In my case, the warnings are actually on neither tbody nor colgroup. When rendering server-side, the app uses a fairly truncated Html component that when thrown to renderToStaticMarkup produces errors like the following:

Warning: validateDOMNesting(...): <title> cannot appear as a child of <html>. See Html > html > title.

However, the following passes the w3’s validator and is rendered correctly because the head tag can be omitted here:

<!DOCTYPE html>
<html>
<title>Test</title>
<p></p>
</html>

So far, I’m only encountering a few warnings - and I’m ignoring them. Are you aware of problems this can cause in the React world?

0reactions
gaearoncommented, Oct 4, 2017

I think we’ll close this. It’s not hard to type extra tbody by hand, and doing this implicitly can lead to surprises.

Read more comments on GitHub >

github_iconTop Results From Across the Web

validateDOMNesting: #text cannot appear as a child of <tr ...
I wrapped my text with <td> elements and the warning disappeared. When I did this, having a whitespace in my text or having...
Read more >
<div> cannot appear as a child of <table> - You.com - You.com
Warning : validateDOMNesting(...): Whitespace text nodes cannot appear as a child of <thead>. Make sure you don't have any extra whitespace between tags...
Read more >
Change Log - Ant Design
Fix Space throws Encountered two children with the same key warning in some cases. #35311. Fix Select tag remove icon position issue.
Read more >
Optional Tags in HTML 4 - Jens Oliver Meiert
IMHO, the most useful statement about optional tags is missing here: not to make use of the option of leaving them out (for...
Read more >
antd/CHANGELOG.en-US.md - UNPKG
88, - Add en-GB missing translations for table. ... 165, - Fix Empty description validateDOMNesting warning.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found