Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Return multiple <tr> lines in React

I would like to be able to return 2 <tr> lines, which works by wrapping in a <tbody> as suggested here:

var Item = React.createClass({
    render: function() {
        return (
            <tbody>
                <tr>/*...*/</tr>
                <tr>/*...*/</tr>
            </tbody>
        );  
    }   
});

However, I get a warning from React: < tbody> cannot appear as a child of < tbody>

Is there any other way to do this that would be more DOM friendly?

like image 308
Ryan McClure Avatar asked Apr 10 '26 14:04

Ryan McClure


1 Answers

That's an annoying limitation of React right now. A <table> can contain multiple <tbody> though -- would rendering <Item> as an additional <tbody> within <table> work for you?

like image 170
JMM Avatar answered Apr 12 '26 18:04

JMM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!