Skip to content

Instantly share code, notes, and snippets.

@tobyhede
Created May 20, 2014 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobyhede/635b8212f9d0e57baeca to your computer and use it in GitHub Desktop.
Save tobyhede/635b8212f9d0e57baeca to your computer and use it in GitHub Desktop.
<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