weisk
4/16/2014 - 6:44 PM

This is how a React repeater control is made (housing html at https://gist.github.com/StoneCypher/10919111 )

This is how a React repeater control is made (housing html at https://gist.github.com/StoneCypher/10919111 )

/** @jsx React.DOM */

'use strict';

var RepeaterRow = React.createClass({

    render: function() {
        return <div>Repeater Row {this.props['data-ex']}</div>;
    }

});



var Repeater = React.createClass({

    render: function() {

        var rows = [];
        this.props.products.forEach(function(product) {

            rows.push(<RepeaterRow key="" data-ex={product.name} />);

        }.bind(this));

        return <div>{rows}</div>;

    }

});



var TestEx = [

    { name: "test 1" },
    { name: "test 2" },
    { name: "test 3" }

];



React.renderComponent(<Repeater products={TestEx} />, document.body);