title: I'm having trouble writing a for loop in react.js
body: <p>I'm new to programming and I'm learning Facebook's react.js. I found a website that has a tutorial which builds a "shopping cart" using react. I tried to modify it to add more items using a for loop but it keeps giving me "unexpected token }" errors followed by this error:</p>
  
  <p>"Invariant Violation: FluxProduct.render(): A valid ReactComponent must be returned. You may have returned undefined, an array or some other invalid object."</p>
  
  <p>I realize there is a similar question that was answered but it didn't help me.</p>
  
  <p>There is quite a bit of code in this project but the particular spot I'm having trouble with looks like this:</p>
  
  <pre><code>render: function() {
      var rows = [];
      var ats = (this.props.selected.sku in this.props.cartitems) ?
        this.props.selected.inventory - this.props.cartitems[this.props.selected.sku].quantity :
        this.props.selected.inventory;
      for (var i=0; i&lt;2; i++){&lt;div className="flux-products"&gt;
          &lt;img src={'img/' + this.props.product.image}/&gt;
          &lt;div className="flux-products-detail"&gt;
            &lt;h1 className="name"&gt;{this.props.product.name}&lt;/h1&gt;
            &lt;p className="description"&gt;{this.props.product.description}&lt;/p&gt;
            &lt;p className="price"&gt;Price: ${this.props.selected.price}&lt;/p&gt;
            &lt;select onChange={this.selectVariant}&gt;
              {this.props.product.variants.map(function(variant, index){
                return (
                  &lt;option key={index} value={index}&gt;{variant.type}&lt;/option&gt;
                )
              })}
            &lt;/select&gt;
            &lt;button type="button" onClick={this.addToCart} disabled={ats  &gt; 0 ? '' : 'disabled'}&gt;
              {ats &gt; 0 ? 'Add To Cart' : 'Sold Out'}
            &lt;/button&gt;
          &lt;/div&gt;
        &lt;/div&gt;}
      return ("flux-products-detail"
  
      );
    },
  
  });
  </code></pre>
  
  <p>If you want/need the original code and the rest of the project I'd be more than happy to provide it.</p>