title: How to display an array of objects in a table in react
body: <p>I have recently been learning react. I set my state to an array of objects. I want to display that array in a table on the page (each object on one line). I have been researching map, however I'm having a bit of trouble understanding it. I was able to use map just fine at a different place in my code to map through an <strong>array</strong>, but I am having trouble mapping through an <strong>array of objects</strong>. This code takes place in the div inside my render:</p>
  
  <pre><code>&lt;table&gt;
    {this.state.orderDetails.map((item =&gt;
    &lt;tr key={item}&gt;{item}&lt;/tr&gt;
    ))}
  &lt;/table&gt;
  </code></pre>
  
  <p>I am getting this error: 'Unhandled Rejection (Error): Objects are not valid as a React child (found: object with keys {OrderID, CustomerID, AddressID, Date, ItemID, BookID, UnitPrice, Quantity}). If you meant to render a collection of children, use an array instead.'</p>
  
  <p>Order details has definitely been set correctly; when I open my react tools and check the state in this component, it is listed as an array with two elements, each element being an object with multiple elements within. How can I successfully map through this array of objects and display it in table form (with each object on its own row)? Thanks is advance for any ideas!!!</p>
  
  <p><strong><em>EDIT</em></strong>
  After taking some advice from the answers and comments, I have changed my map to the following:</p>
  
  <pre><code>&lt;table&gt;
    {this.state.orderDetails.map((item =&gt;
    &lt;tr&gt;&lt;td key={item.OrderID}&gt;{item.CustomerID}&lt;/td&gt;&lt;/tr&gt;
    ))}
  &lt;/table&gt;
  </code></pre>
  
  <p>The error has gone away. However, when I click the button, I get one tiny table cell that is empty. I would expect multiple cells since my array has two objects, and of course I would expect it not to be empty. Also, I am wanting to display more than just customerID. I have several elements in each object that I want to render on the table (ex. quantity, price, title, etc...). Any further sugesstions?</p>