title: reactjs cannot read property 'forEach' of undefined
body: <p>i am getting the products array from a parent element and trying to loop through it using forEach. instead i am getting an error "Uncaught TypeError: Cannot read property 'forEach' of undefined at ProductTable.render". the console.log(rows) outputs the array of objects though. </p>
  
  <p>below is my ProductTable component </p>
  
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import {ProductCategoryRow}  from './productcategoryrow.js';
  import {ProductRow} from './productrow.js'
  
  export class ProductTable extends React.Component {    
      render(){
         let rows =[];
         let lastcategory = null;
         this.props.products.forEach(function(product){
  
              if(product.category !== lastcategory){
                  rows.push(&lt;ProductCategoryRow category = {product.category} key={product.category}/&gt;);
              }
              rows.push(&lt;ProductTable product={product} key={product.name}/&gt;);
              lastcategory = product.category;
  
         });
         console.log(rows);
         return(
             &lt;div&gt;
               &lt;table&gt;
                  &lt;thead&gt;
                      &lt;tr&gt;
                          &lt;td&gt;Name&lt;/td&gt;
                          &lt;td&gt;Price&lt;/td&gt;
                      &lt;/tr&gt;
  
                          {rows}
  
                  &lt;/thead&gt;
               &lt;/table&gt;
             &lt;/div&gt;
          );
      }
  }
  </code></pre>
  
  <p>below is it's parent component from where the props are being passed: </p>
  
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import {SearchBar} from './searchbar.js';
  import {ProductTable} from './producttable.js';
  
  
  class FilterableProductTable extends React.Component{
    render(){
      return(
            &lt;div&gt;
            &lt;SearchBar/&gt;
            &lt;ProductTable products = {this.props.products}/&gt;
            &lt;/div&gt;
        );
    }
  }
  
  var PRODUCTS = [
    {category: 'Sporting Goods', price: '$49.99', stocked: true, name: 'Football'},
    {category: 'Sporting Goods', price: '$9.99', stocked: true, name: 'Baseball'},
    {category: 'Sporting Goods', price: '$29.99', stocked: false, name: 'Basketball'},
    {category: 'Electronics', price: '$99.99', stocked: true, name: 'iPod Touch'},
    {category: 'Electronics', price: '$399.99', stocked: false, name: 'iPhone 5'},
    {category: 'Electronics', price: '$199.99', stocked: true, name: 'Nexus 7'}
  ];
  
  
  ReactDOM.render(&lt;FilterableProductTable products={PRODUCTS} /&gt;, document.getElementById('container'));
  </code></pre>