Skip to content

Instantly share code, notes, and snippets.

@StoneCypher
Created April 16, 2014 18:44
Show Gist options
  • Save StoneCypher/10919150 to your computer and use it in GitHub Desktop.
Save StoneCypher/10919150 to your computer and use it in GitHub Desktop.
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment