REACT ERROR cannot appear as a child of . See (unknown) > thead > th











up vote
21
down vote

favorite
2












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










share|improve this question




















  • 1




    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















up vote
21
down vote

favorite
2












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










share|improve this question




















  • 1




    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













up vote
21
down vote

favorite
2









up vote
21
down vote

favorite
2






2





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










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 13 '17 at 23:04

























asked May 13 '17 at 22:50









DianaBG

1311111




1311111








  • 1




    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














  • 1




    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








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












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>





share|improve this answer



















  • 2




    I would've never expected React to teach me something about HTML!
    – Matt Fletcher
    Feb 26 at 8:19


















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>








share|improve this answer























  • 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


















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.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    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

























    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>





    share|improve this answer



















    • 2




      I would've never expected React to teach me something about HTML!
      – Matt Fletcher
      Feb 26 at 8:19















    up vote
    32
    down vote













    The only direct children allowed for thead are tr elements, not th.



    <table>
    <thead>
    <tr>
    <th />
    </tr>
    </thead>
    ...
    </table>





    share|improve this answer



















    • 2




      I would've never expected React to teach me something about HTML!
      – Matt Fletcher
      Feb 26 at 8:19













    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>





    share|improve this answer














    The only direct children allowed for thead are tr elements, not th.



    <table>
    <thead>
    <tr>
    <th />
    </tr>
    </thead>
    ...
    </table>






    share|improve this answer














    share|improve this answer



    share|improve this answer








    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














    • 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












    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>








    share|improve this answer























    • 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















    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>








    share|improve this answer























    • 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













    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>








    share|improve this answer














    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>






    share|improve this answer














    share|improve this answer



    share|improve this answer








    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


















    • 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










    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.






    share|improve this answer

























      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.






      share|improve this answer























        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 16 '17 at 6:05









        J.McLaren

        7114




        7114






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks