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.

Warning: validateDOMNesting(...): <tr> cannot appear as a child of <table>

See original GitHub issue

Using react and react-dom v0.14.3. Have a component which renders:

 <table style={tableStyle}>
       <tr style={rowStyle}>
           <td style={leftColumnStyle}>Battery</td>
           <td><StatsBar/></td>
        </tr>
        ...
  </table>

Getting an error message in console: Warning: validateDOMNesting(...): <tr> cannot appear as a child of <table>. See ProductDetails > table > tr. Add a <tbody> to your code to match the DOM tree generated by the browser.

Any ideas why?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:16
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

214reactions
waldreitercommented, Dec 12, 2015

Just do what the warning suggests:

<table style={tableStyle}>
   <tbody>
       <tr style={rowStyle}>
           <td style={leftColumnStyle}>Battery</td>
           <td><StatsBar/></td>
        </tr>
   </tbody>
</table>

Browsers need the <tbody> tag. If it is not in your code, then the browser will automatically insert it. This will work fine on first render, but when the table gets updated, then the DOM tree is different from what React expects. This can give strange bugs, therefore React warns you to insert the <tbody>. It is a really helpful warning.

9reactions
username99987commented, Dec 12, 2015

Ah makes sense. Problem solved, thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

validateDOMNesting(...): <tr> cannot appear as a child of <div>
This will work fine on first render, but when the table gets updated, then the DOM tree is different from what React expects....
Read more >
<tr> cannot appear as a child of <table>. Add a <tbody ...
I keep getting the warning on the title. I followed… ... Warning: validateDOMNesting(...): <tr> cannot appear as a child of <table>.
Read more >
<tr> cannot appear as a child of <table>. - Warning
I am seeing the following warning when opening the Messages panel. Warning: validateDOMNesting(...): <tr> cannot appear as a child of <table>.
Read more >
validatedomnesting(...): <div> cannot appear as a child of ...
I cannot seem to fix the error no matter how I rearrange the order of the table footer in relation to the table...
Read more >
23 - Warning: validateDOMNesting(...):cannot appear as a child
Warning : validateDOMNesting (...): cannot appear as a child , Concept Fragments in React .Watch Full Part of this Series ...
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