Warning: validateDOMNesting(...): <tr> cannot appear as a child of <table>
See original GitHub issueUsing 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:
- Created 8 years ago
- Reactions:16
- Comments:12 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just do what the warning suggests:
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.Ah makes sense. Problem solved, thanks.