CS-Notes/docs/_style/prism-master/examples/prism-jsx.html

19 lines
598 B
Java
Raw Normal View History

2018-12-19 14:09:39 +08:00
<h2>Full example</h2>
<pre><code>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 &lt;p>{message}&lt;/p>;
}
});
var start = new Date().getTime();
setInterval(function() {
React.render(
&lt;ExampleApplication elapsed={new Date().getTime() - start} />,
document.getElementById('container')
);
}, 50);</code></pre>