Skip to content

Instantly share code, notes, and snippets.

@tobyhede tobyhede/react.js
Created May 20, 2014

Embed
What would you like to do?
<script type="text/jsx">
/** @jsx React.DOM */
var AppList = React.createClass({
render: function() {
var elements = this.state.apps.map(function(app) {
return <AppElement app={app} />
})
return <ul>{elements}</ul>;
},
getInitialState: function() {
return {apps: []};
},
componentDidMount: function() {
$.get(this.props.source, function(result) {
this.setState({
apps: result
})
}.bind(this));
}
});
var AppElement = React.createClass({
render: function() {
return <li key={this.props.app.Id}>{this.props.app.Name}</li>;
},
});
node = document.getElementById("content");
React.renderComponent(<AppList source="/apps.json" />, node);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.