LRP React Demos

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 Name = React.createClass({
    getInitialState: function() {
        return {
            name: this.props.children
        };
    },
    clickme: function() {
        this.setState({name: this.state.name.split("").reverse().join("")});
    },
    render: function() {
        return (
            <span onClick={this.clickme}>{this.state.name}</span>
        );
    }
});

var Hello = React.createClass({
    render: function() {
        return (
            <div>
                <span>Hello&nbsp;</span>
                <Name>{this.props.name}</Name>
            </div>)
        ;
    }
});
 
React.render(<Hello name="World" />, document.getElementById('container'));