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

function needToMoveOnTop() {
    return true;
}

var Test = React.createClass({
    getInitialState: function() {
        return {top: false}
    },
    
    componentDidUpdate: function() {
        if (this.state.top == true) {
            this.setState({top: false});
        }
        if (needToMoveOnTop()) {
            this.setState({top: true});
        }
    },
    
    //componentDidUpdate: function() {
    //    var shouldBeOnTop = false;
    //    if (needToMoveOnTop()) {
    //        shouldBeOnTop = true;
    //    }
    //    if (this.state.top != shouldBeOnTop) {
    //        this.setState({top: shouldBeOnTop});
    //    }
    //},
    
    rerender: function() {
        this.setState({});
    },
    
    render: function() {
        return (
            <div>
                <button onClick={this.rerender}>rerender</button>
                <div>{this.state.top.toString()}</div>
            </div>
        );
    }
});
 
var hello = React.render(<Test/>, document.getElementById('container'));