React Base Fiddle (JSX)

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

by btipling

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({
  childContextTypes: {
    foo: React.PropTypes.string,
    foobar: React.PropTypes.string
  },
  getChildContext: function() {
    return {foo: 'foo', foobar: 'foobar1'};
  },
  render: function() {
  	return <SuperNestedHello name={'Super ' + this.props.name} />;
  }
});

var SuperNestedHello = React.createClass({
  childContextTypes: {
    bar: React.PropTypes.string,
    foobar: React.PropTypes.string
  },
  getChildContext: function() {
    return {bar: 'bar', foobar: 'foobar2'};
  },
	render: function () {
  	return <NestedHello name={'Nested ' + this.props.name} />;
  },
});

var NestedHello = React.createClass({
	contextTypes: {
    foo: React.PropTypes.string,
    bar: React.PropTypes.string,
  	foobar: React.PropTypes.string,
  },
	render: function () {
    return <div>
    	<p>Hello {this.props.name}</p>
    	<p>Your foo: {this.context.foo}</p>
    	<p>Your bar: {this.context.bar}</p>
      <p>Your foobar: {this.context.foobar}</p>
    </div>;
  }
});

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