title: How do I wrap a React component that returns multiple table rows and avoid the "<tr> cannot appear as a child of <div>" error?
body: <p>I have a component called OrderItem that takes an object with multiple objects (at least two) inside it, and renders them as multiple rows inside a table.  There will be multiple OrderItem components inside the table. The problem is that in the component's render function, I can't return multiple  lines.  I can only return a single component, and if I wrap them in a div, it says " <code>&lt;tr&gt;</code> cannot appear as a child of <code>&lt;div&gt;</code>"</p>
  
  <p>The code looks something like this (I left some stuff out for easier readability)</p>
  
  <pre class="lang-js prettyprint-override"><code>Parent() {
    render() {
      return (
        &lt;table&gt;
          &lt;tbody&gt;
            {
              _.map(this.state.orderItems, (value, key) =&gt; {
                return &lt;OrderItem value={value} myKey={key}/&gt;
              })
            }
          &lt;/tbody&gt;
        &lt;/table&gt;
      )
    }
  }
  
  class OrderItem extends React.Component {
    render() {
      return (
        &lt;div&gt; // &lt;-- problematic div
          &lt;tr key={this.props.myKey}&gt;
            &lt;td&gt; Table {this.props.value[0].table}&lt;/td&gt;
            &lt;td&gt; Item &lt;/td&gt;
            &lt;td&gt; Option &lt;/td&gt;
          &lt;/tr&gt;
          {this.props.value.map((item, index) =&gt; {
            if (index &gt; 0) { // skip the first element since it's already used above
              return (
                &lt;tr key={this.props.myKey + index.toString()}&gt;
                  &lt;td&gt;&lt;img src={item.image} alt={item.name} width="50"/&gt; {item.name}&lt;/td&gt;
                  &lt;td&gt;{item.selectedOption}&lt;/td&gt;
                &lt;/tr&gt;
              )
            }
          })}
        &lt;/div&gt;
      )
    }
  }
  </code></pre>
  
  <p>Is there a way I can return those multiple rows and have them be in the same table without wrapping them in a div and getting an error?  I realize I can make a separate table for each component, but that throws my formatting off a bit.</p>