例子1:React基本用法

示例代码

    var ExampleApplication = React.createClass({
        render: function() {
            var elapsed = Math.round(this.props.elapsed  / 100);
            var seconds = elapsed / 10 + (elapsed % 10 ? '' : '.0' );
            var message = 'React has been successfully running for ' + seconds + ' seconds.'

            return React.createElement('span', null, message);
        }
    });

    var start = new Date().getTime();
    setInterval(function() {
        React.render(
                React.createElement(ExampleApplication, {elapsed: new Date().getTime() - start}),
                document.getElementById('sampleContainer')
        );
    }, 50);
    

展示效果