Created
May 20, 2014 04:17
-
-
Save tobyhede/635b8212f9d0e57baeca to your computer and use it in GitHub Desktop.
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
<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