Skip to content

Instantly share code, notes, and snippets.

@rahmanusta
Created February 26, 2016 14:22
Show Gist options
  • Save rahmanusta/c3d03a2d520868e3d5df to your computer and use it in GitHub Desktop.
Save rahmanusta/c3d03a2d520868e3d5df to your computer and use it in GitHub Desktop.
React Iteration example
var NameRow = React.createClass({
getInitialState: function () {
return {
names: this.props.names || []
};
},
render: function () {
return (<div>
<ul>
{this.state.names.map(function (e) {
return (<li key={e.id}>{e.name}</li>);
})}
</ul>
</div>);
}
});
var NAMES = [
{
id: 1,
name: "Rahman"
},
{
id: 2,
name: "Hakan"
},
{
id: 3,
name: "Ayşe"
},
];
ReactDOM.render(<NameRow names={NAMES}/>, document.querySelector("#root"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment