React Base Fiddle (JSX)
Starting point for creating JSFiddles with React. This uses React with Addons.
HTML
<script src="http://fb.me/JSXTransformer-0.12.1.js"></script>
<script src="http://fb.me/react-with-addons-0.12.1.js"></script>
<script src="http://facebook.github.io/react/js/jsfiddle-integration.js"></script>
<div id="content"></div>
JavaScript 1.7
var ImageCollect = React.createClass({
getInitialState: function() {
return {
pImage: []
};
},
componentDidMount: function() {
var self = this;
$.get(this.props.source, function(result) {
var collection = result.data.children;
if (this.isMounted()) {
this.setState({
pImage: collection.data.thumbnail
});
}
}.bind(this));
},
render: function() {
return (
<div>
Images: {this.state.pImage}
</div>
);
}
});
React.renderComponent(
<ImageCollect source="http://www.reddit.com/r/pics/top/.json" />,
document.getElementById('content')
);