React Base Fiddle (JSX)

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

by justindeal

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="app">
    <!-- This element's contents will be replaced with your component. -->
</div>

JavaScript 1.7

const Outer = React.createClass({

  childContextTypes: {
    x: React.PropTypes.number
  },

  getChildContext() {
    return {x: this.props.x};
  },

  render() {
    return (
      <span>{this.props.children}</span>
    );
  }
});

const Inner = React.createClass({

  contextTypes: {
    x: React.PropTypes.number
  },

  // If you remove this, it will work.
  // mixins: [React.addons.PureRenderMixin],

  render() {
    return (
      <span>x: {this.context.x}</span>
    );
  }
});

// This will render fine.
React.render(<Outer x={5}><Inner/></Outer>, document.getElementById('app'));
// This will not update anything.
//React.render(<Outer/>, document.getElementById('app'));