Created
April 16, 2014 18:44
-
-
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 )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @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