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/react/0.13.1/JSXTransformer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.1/react-with-addons.js"></script>
<script src="https://facebook.github.io/react/js/jsfiddle-integration.js"></script>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>
JavaScript 1.7
var counter = 0;
const Hello = React.createClass({
getInitialState: function() {
return {button: "click me", list: ""}
},
myClick: function () {
counter++;
this.setState({
button: "loading...",
list: ""
})
setTimeout(() => {
const arr = Array(parseInt(Math.random() * 10)).fill(0).map((e,idx) => {return <li>line {idx}</li>})
this.setState({
button: "click me " + counter,
list: arr
})
}, 1000); // simulate network request
},
render: function() {
return <div><button onClick={this.myClick}>
{this.state.button}
</button>
<ul>{this.state.list}</ul></div>
}
});
React.render(<Hello />, document.getElementById('container'));