Created
February 26, 2016 14:22
-
-
Save rahmanusta/c3d03a2d520868e3d5df to your computer and use it in GitHub Desktop.
React Iteration example
This file contains 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
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