REACT ERROR cannot appear as a child of . See (unknown) > thead > th
up vote
21
down vote
favorite
I am working on a react - rails app and I keep getting this error in my console:
```
Warning: validateDOMNesting(...): <th> cannot appear as a child of <thead>.
See (unknown) > thead > th.
I'm not sure why this isn't working..I want to use header (thead) for a table and it worked for someone else. I would put tbody but I need that for the actual body of the table.
here is my code for this table:
```
React.DOM.table
className: 'table table-bordered'
React.DOM.thead null,
React.DOM.th null, 'Description'
React.DOM.th null, 'Actions'
React.DOM.tbody null,
for post in @state.posts
React.createElement Post, key: post.id, post: post,
handleDeletePost: @deletePost
**EDIT
I have tried adding the tr tag under thead and that causes an extra added error. this is what I changed my code to:
```
React.DOM.table
className: 'table table-bordered'
React.DOM.thead null
React.DOM.tr null
React.DOM.th null, 'Description'
React.DOM.th null, 'Actions'
React.DOM.tbody null,
for post in @state.posts
React.createElement Post, key: post.id, post: post,
handleDeletePost: @deletePost
and the next error i get is: Warning: validateDOMNesting(...): tr cannot appear as a child of table. See (unknown) > table > tr. Add a to your code to match the DOM tree generated by the browser.
I'm new to react and not familiar with coffeescript so I'm wondering if it has to do with the spacing or something. Tested out different spacing and that didn't help. I took out the thead all together and that caused my app to break so..not sure what's the problem
javascript jquery ruby-on-rails reactjs
add a comment |
up vote
21
down vote
favorite
I am working on a react - rails app and I keep getting this error in my console:
```
Warning: validateDOMNesting(...): <th> cannot appear as a child of <thead>.
See (unknown) > thead > th.
I'm not sure why this isn't working..I want to use header (thead) for a table and it worked for someone else. I would put tbody but I need that for the actual body of the table.
here is my code for this table:
```
React.DOM.table
className: 'table table-bordered'
React.DOM.thead null,
React.DOM.th null, 'Description'
React.DOM.th null, 'Actions'
React.DOM.tbody null,
for post in @state.posts
React.createElement Post, key: post.id, post: post,
handleDeletePost: @deletePost
**EDIT
I have tried adding the tr tag under thead and that causes an extra added error. this is what I changed my code to:
```
React.DOM.table
className: 'table table-bordered'
React.DOM.thead null
React.DOM.tr null
React.DOM.th null, 'Description'
React.DOM.th null, 'Actions'
React.DOM.tbody null,
for post in @state.posts
React.createElement Post, key: post.id, post: post,
handleDeletePost: @deletePost
and the next error i get is: Warning: validateDOMNesting(...): tr cannot appear as a child of table. See (unknown) > table > tr. Add a to your code to match the DOM tree generated by the browser.
I'm new to react and not familiar with coffeescript so I'm wondering if it has to do with the spacing or something. Tested out different spacing and that didn't help. I took out the thead all together and that caused my app to break so..not sure what's the problem
javascript jquery ruby-on-rails reactjs
1
It should bethead > tr > th
– zerkms
May 13 '17 at 22:52
I had typedthread
instead ofthead
– ArtiomLK
May 27 at 17:48
add a comment |
up vote
21
down vote
favorite
up vote
21
down vote
favorite
I am working on a react - rails app and I keep getting this error in my console:
```
Warning: validateDOMNesting(...): <th> cannot appear as a child of <thead>.
See (unknown) > thead > th.
I'm not sure why this isn't working..I want to use header (thead) for a table and it worked for someone else. I would put tbody but I need that for the actual body of the table.
here is my code for this table:
```
React.DOM.table
className: 'table table-bordered'
React.DOM.thead null,
React.DOM.th null, 'Description'
React.DOM.th null, 'Actions'
React.DOM.tbody null,
for post in @state.posts
React.createElement Post, key: post.id, post: post,
handleDeletePost: @deletePost
**EDIT
I have tried adding the tr tag under thead and that causes an extra added error. this is what I changed my code to:
```
React.DOM.table
className: 'table table-bordered'
React.DOM.thead null
React.DOM.tr null
React.DOM.th null, 'Description'
React.DOM.th null, 'Actions'
React.DOM.tbody null,
for post in @state.posts
React.createElement Post, key: post.id, post: post,
handleDeletePost: @deletePost
and the next error i get is: Warning: validateDOMNesting(...): tr cannot appear as a child of table. See (unknown) > table > tr. Add a to your code to match the DOM tree generated by the browser.
I'm new to react and not familiar with coffeescript so I'm wondering if it has to do with the spacing or something. Tested out different spacing and that didn't help. I took out the thead all together and that caused my app to break so..not sure what's the problem
javascript jquery ruby-on-rails reactjs
I am working on a react - rails app and I keep getting this error in my console:
```
Warning: validateDOMNesting(...): <th> cannot appear as a child of <thead>.
See (unknown) > thead > th.
I'm not sure why this isn't working..I want to use header (thead) for a table and it worked for someone else. I would put tbody but I need that for the actual body of the table.
here is my code for this table:
```
React.DOM.table
className: 'table table-bordered'
React.DOM.thead null,
React.DOM.th null, 'Description'
React.DOM.th null, 'Actions'
React.DOM.tbody null,
for post in @state.posts
React.createElement Post, key: post.id, post: post,
handleDeletePost: @deletePost
**EDIT
I have tried adding the tr tag under thead and that causes an extra added error. this is what I changed my code to:
```
React.DOM.table
className: 'table table-bordered'
React.DOM.thead null
React.DOM.tr null
React.DOM.th null, 'Description'
React.DOM.th null, 'Actions'
React.DOM.tbody null,
for post in @state.posts
React.createElement Post, key: post.id, post: post,
handleDeletePost: @deletePost
and the next error i get is: Warning: validateDOMNesting(...): tr cannot appear as a child of table. See (unknown) > table > tr. Add a to your code to match the DOM tree generated by the browser.
I'm new to react and not familiar with coffeescript so I'm wondering if it has to do with the spacing or something. Tested out different spacing and that didn't help. I took out the thead all together and that caused my app to break so..not sure what's the problem
javascript jquery ruby-on-rails reactjs
javascript jquery ruby-on-rails reactjs
edited May 13 '17 at 23:04
asked May 13 '17 at 22:50
DianaBG
1311111
1311111
1
It should bethead > tr > th
– zerkms
May 13 '17 at 22:52
I had typedthread
instead ofthead
– ArtiomLK
May 27 at 17:48
add a comment |
1
It should bethead > tr > th
– zerkms
May 13 '17 at 22:52
I had typedthread
instead ofthead
– ArtiomLK
May 27 at 17:48
1
1
It should be
thead > tr > th
– zerkms
May 13 '17 at 22:52
It should be
thead > tr > th
– zerkms
May 13 '17 at 22:52
I had typed
thread
instead of thead
– ArtiomLK
May 27 at 17:48
I had typed
thread
instead of thead
– ArtiomLK
May 27 at 17:48
add a comment |
3 Answers
3
active
oldest
votes
up vote
32
down vote
The only direct children allowed for thead
are tr
elements, not th
.
<table>
<thead>
<tr>
<th />
</tr>
</thead>
...
</table>
2
I would've never expected React to teach me something about HTML!
– Matt Fletcher
Feb 26 at 8:19
add a comment |
up vote
17
down vote
Well th
should be nested under a tr
not a thead
. Docs
<table>
<thead>
<tr>
<th>name</th>
<th>age</th>
</tr>
</thead>
<tbody>
<tr>
<td>john</td>
<td>33</td>
</tr>
<tr>
<td>smith</td>
<td>22</td>
</tr>
<tr>
<td>jane</td>
<td>24</td>
</tr>
</tbody>
</table>
I've tried adding tr to my code under thead but it gives me an extra error.
– DianaBG
May 13 '17 at 23:00
```React.DOM.table className: 'table table-bordered' React.DOM.thead null React.DOM.tr null React.DOM.th null, 'Description' React.DOM.th null, 'Actions' React.DOM.tbody null, for post in @state.posts React.createElement Post, key: post.id, post: post, handleDeletePost: @deletePost
– DianaBG
May 13 '17 at 23:01
i still then have my original error as well as "tr cannot appear as a child of table" and
– DianaBG
May 13 '17 at 23:02
1
Thank you Sagiv b.g it was helpful
– Enoy
Feb 13 at 8:04
add a comment |
up vote
2
down vote
I've had this error come up because of mistakes elsewhere in my list.
For example @Sag1v has <tbody>
instead of </tbody>
to close the body of his list and I bet that is causing the error.
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
32
down vote
The only direct children allowed for thead
are tr
elements, not th
.
<table>
<thead>
<tr>
<th />
</tr>
</thead>
...
</table>
2
I would've never expected React to teach me something about HTML!
– Matt Fletcher
Feb 26 at 8:19
add a comment |
up vote
32
down vote
The only direct children allowed for thead
are tr
elements, not th
.
<table>
<thead>
<tr>
<th />
</tr>
</thead>
...
</table>
2
I would've never expected React to teach me something about HTML!
– Matt Fletcher
Feb 26 at 8:19
add a comment |
up vote
32
down vote
up vote
32
down vote
The only direct children allowed for thead
are tr
elements, not th
.
<table>
<thead>
<tr>
<th />
</tr>
</thead>
...
</table>
The only direct children allowed for thead
are tr
elements, not th
.
<table>
<thead>
<tr>
<th />
</tr>
</thead>
...
</table>
edited May 13 '17 at 23:02
answered May 13 '17 at 22:54
Bertrand Marron
15.2k74281
15.2k74281
2
I would've never expected React to teach me something about HTML!
– Matt Fletcher
Feb 26 at 8:19
add a comment |
2
I would've never expected React to teach me something about HTML!
– Matt Fletcher
Feb 26 at 8:19
2
2
I would've never expected React to teach me something about HTML!
– Matt Fletcher
Feb 26 at 8:19
I would've never expected React to teach me something about HTML!
– Matt Fletcher
Feb 26 at 8:19
add a comment |
up vote
17
down vote
Well th
should be nested under a tr
not a thead
. Docs
<table>
<thead>
<tr>
<th>name</th>
<th>age</th>
</tr>
</thead>
<tbody>
<tr>
<td>john</td>
<td>33</td>
</tr>
<tr>
<td>smith</td>
<td>22</td>
</tr>
<tr>
<td>jane</td>
<td>24</td>
</tr>
</tbody>
</table>
I've tried adding tr to my code under thead but it gives me an extra error.
– DianaBG
May 13 '17 at 23:00
```React.DOM.table className: 'table table-bordered' React.DOM.thead null React.DOM.tr null React.DOM.th null, 'Description' React.DOM.th null, 'Actions' React.DOM.tbody null, for post in @state.posts React.createElement Post, key: post.id, post: post, handleDeletePost: @deletePost
– DianaBG
May 13 '17 at 23:01
i still then have my original error as well as "tr cannot appear as a child of table" and
– DianaBG
May 13 '17 at 23:02
1
Thank you Sagiv b.g it was helpful
– Enoy
Feb 13 at 8:04
add a comment |
up vote
17
down vote
Well th
should be nested under a tr
not a thead
. Docs
<table>
<thead>
<tr>
<th>name</th>
<th>age</th>
</tr>
</thead>
<tbody>
<tr>
<td>john</td>
<td>33</td>
</tr>
<tr>
<td>smith</td>
<td>22</td>
</tr>
<tr>
<td>jane</td>
<td>24</td>
</tr>
</tbody>
</table>
I've tried adding tr to my code under thead but it gives me an extra error.
– DianaBG
May 13 '17 at 23:00
```React.DOM.table className: 'table table-bordered' React.DOM.thead null React.DOM.tr null React.DOM.th null, 'Description' React.DOM.th null, 'Actions' React.DOM.tbody null, for post in @state.posts React.createElement Post, key: post.id, post: post, handleDeletePost: @deletePost
– DianaBG
May 13 '17 at 23:01
i still then have my original error as well as "tr cannot appear as a child of table" and
– DianaBG
May 13 '17 at 23:02
1
Thank you Sagiv b.g it was helpful
– Enoy
Feb 13 at 8:04
add a comment |
up vote
17
down vote
up vote
17
down vote
Well th
should be nested under a tr
not a thead
. Docs
<table>
<thead>
<tr>
<th>name</th>
<th>age</th>
</tr>
</thead>
<tbody>
<tr>
<td>john</td>
<td>33</td>
</tr>
<tr>
<td>smith</td>
<td>22</td>
</tr>
<tr>
<td>jane</td>
<td>24</td>
</tr>
</tbody>
</table>
Well th
should be nested under a tr
not a thead
. Docs
<table>
<thead>
<tr>
<th>name</th>
<th>age</th>
</tr>
</thead>
<tbody>
<tr>
<td>john</td>
<td>33</td>
</tr>
<tr>
<td>smith</td>
<td>22</td>
</tr>
<tr>
<td>jane</td>
<td>24</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>name</th>
<th>age</th>
</tr>
</thead>
<tbody>
<tr>
<td>john</td>
<td>33</td>
</tr>
<tr>
<td>smith</td>
<td>22</td>
</tr>
<tr>
<td>jane</td>
<td>24</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>name</th>
<th>age</th>
</tr>
</thead>
<tbody>
<tr>
<td>john</td>
<td>33</td>
</tr>
<tr>
<td>smith</td>
<td>22</td>
</tr>
<tr>
<td>jane</td>
<td>24</td>
</tr>
</tbody>
</table>
edited Nov 21 at 20:20
answered May 13 '17 at 22:57
Sagiv b.g
15.4k21752
15.4k21752
I've tried adding tr to my code under thead but it gives me an extra error.
– DianaBG
May 13 '17 at 23:00
```React.DOM.table className: 'table table-bordered' React.DOM.thead null React.DOM.tr null React.DOM.th null, 'Description' React.DOM.th null, 'Actions' React.DOM.tbody null, for post in @state.posts React.createElement Post, key: post.id, post: post, handleDeletePost: @deletePost
– DianaBG
May 13 '17 at 23:01
i still then have my original error as well as "tr cannot appear as a child of table" and
– DianaBG
May 13 '17 at 23:02
1
Thank you Sagiv b.g it was helpful
– Enoy
Feb 13 at 8:04
add a comment |
I've tried adding tr to my code under thead but it gives me an extra error.
– DianaBG
May 13 '17 at 23:00
```React.DOM.table className: 'table table-bordered' React.DOM.thead null React.DOM.tr null React.DOM.th null, 'Description' React.DOM.th null, 'Actions' React.DOM.tbody null, for post in @state.posts React.createElement Post, key: post.id, post: post, handleDeletePost: @deletePost
– DianaBG
May 13 '17 at 23:01
i still then have my original error as well as "tr cannot appear as a child of table" and
– DianaBG
May 13 '17 at 23:02
1
Thank you Sagiv b.g it was helpful
– Enoy
Feb 13 at 8:04
I've tried adding tr to my code under thead but it gives me an extra error.
– DianaBG
May 13 '17 at 23:00
I've tried adding tr to my code under thead but it gives me an extra error.
– DianaBG
May 13 '17 at 23:00
```React.DOM.table className: 'table table-bordered' React.DOM.thead null React.DOM.tr null React.DOM.th null, 'Description' React.DOM.th null, 'Actions' React.DOM.tbody null, for post in @state.posts React.createElement Post, key: post.id, post: post, handleDeletePost: @deletePost
– DianaBG
May 13 '17 at 23:01
```React.DOM.table className: 'table table-bordered' React.DOM.thead null React.DOM.tr null React.DOM.th null, 'Description' React.DOM.th null, 'Actions' React.DOM.tbody null, for post in @state.posts React.createElement Post, key: post.id, post: post, handleDeletePost: @deletePost
– DianaBG
May 13 '17 at 23:01
i still then have my original error as well as "tr cannot appear as a child of table" and
– DianaBG
May 13 '17 at 23:02
i still then have my original error as well as "tr cannot appear as a child of table" and
– DianaBG
May 13 '17 at 23:02
1
1
Thank you Sagiv b.g it was helpful
– Enoy
Feb 13 at 8:04
Thank you Sagiv b.g it was helpful
– Enoy
Feb 13 at 8:04
add a comment |
up vote
2
down vote
I've had this error come up because of mistakes elsewhere in my list.
For example @Sag1v has <tbody>
instead of </tbody>
to close the body of his list and I bet that is causing the error.
add a comment |
up vote
2
down vote
I've had this error come up because of mistakes elsewhere in my list.
For example @Sag1v has <tbody>
instead of </tbody>
to close the body of his list and I bet that is causing the error.
add a comment |
up vote
2
down vote
up vote
2
down vote
I've had this error come up because of mistakes elsewhere in my list.
For example @Sag1v has <tbody>
instead of </tbody>
to close the body of his list and I bet that is causing the error.
I've had this error come up because of mistakes elsewhere in my list.
For example @Sag1v has <tbody>
instead of </tbody>
to close the body of his list and I bet that is causing the error.
answered Nov 16 '17 at 6:05
J.McLaren
7114
7114
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43958700%2freact-error-th-cannot-appear-as-a-child-of-thead-see-unknown-thead-th%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
It should be
thead > tr > th
– zerkms
May 13 '17 at 22:52
I had typed
thread
instead ofthead
– ArtiomLK
May 27 at 17:48