React Base Fiddle (JSX)
Starting point for creating JSFiddles with React. This uses React with Addons.
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.js"></script>
<script src="https://fb.me/react-with-addons-0.14.6.js"></script>
<script src="https://fb.me/react-dom-0.14.6.js"></script>
<script src="https://facebook.github.io/react/js/jsfiddle-integration-babel.js"></script>
<script src="https://cmeasy.herokuapp.com/admin/api/v1/content.js"></script>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>
JavaScript 1.7
function getBlogPostContent() {
return window._cmeasy_content.blogPost || [];
}
function getHomePageTitleContent(){
return window._cmeasy_content.homePage[0].title || '';
}
var Title = React.createClass({
render: function() {
return <h1>{this.props.title}</h1>;
}
});
var BlogPost = React.createClass({
getBlogContent: function(){
return {__html: this.props.blog.content};
},
render: function() {
return <div>
<h3>{this.props.blog.title}</h3>
<div dangerouslySetInnerHTML={this.getBlogContent()}></div>
</div>;
}
});
var HomePage = React.createClass({
getInitialState: function() {
return {
title: getHomePageTitleContent(),
blogPosts: getBlogPostContent()
}
},
render: function() {
return <div>
<Title title={this.state.title} />
{
this.state.blogPosts.map(function(blog) {
return <BlogPost blog={blog} />
})
}
</div>;
}
});
ReactDOM.render(
<HomePage />,
document.getElementById('container')
);