React Base Fiddle (JSX)

Starting point for creating JSFiddles with React. This uses React with Addons.

by emn13

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>

<div id="container">
    <!-- This element's contents will be replaced with your component. -->
</div>

JavaScript 1.7

var Hello = React.createClass({
	getInitialState:function() { return { foo: 0 } },
	incFoo:function() { this.setState({foo:this.state.foo+1}) },
	incBar:function() { this.setState({bar:this.state.bar+1||1}) },
	reset_replaceState:function() { this.replaceState(this.getInitialState()) },
	reset_setState:function() { this.setState(this.getInitialState()) },

  render: function() {
    return <ul>
    	<li><button onClick={this.incFoo}>Foo</button> {this.state.foo}</li>
    	<li><button onClick={this.incBar}>Bar</button> {this.state.bar}</li>
    	<li><button onClick={this.reset_replaceState}>reset_replaceState</button></li>
    	<li><button onClick={this.reset_setState}>reset_setState</button></li>
    </ul>;
  }
});

ReactDOM.render(
  <Hello name="World" />,
  document.getElementById('container')
);