<h1>Chapter 01 - StopWatch using React</h1><divid="container"></div>
Create React Component inside a script tag as follows
<script>
var ExampleApplication = React.createClass({render: function(){varelapsed=Math.round(this.props.elapsed/100);varseconds=elapsed/10+(elapsed%10 ? '' : '.0');varmessage='React has been successfully running for '+seconds+' seconds.';returnReact.DOM.p(null,message);}});
// https://facebook.github.io/react/docs/top-level-api.html#react.createfactory
var ExampleApplicationFactory = React.createFactory(ExampleApplication);
var start = new Date().getTime();
setInterval(function() {// https://facebook.github.io/react/docs/top-level-api.html#reactdom.renderReactDOM.render(ExampleApplicationFactory({elapsed: newDate().getTime()-start}),document.getElementById('container'));}, 100);
</script>
Lets initialize this project with npm to help us install a node server. Run the command npm init in terminal under chapter01
(accept all defaults)
Lets install a node http-server using the command npm install --save http-server.
Start node http-server using the command node node_modules/http-server/bin/http-server.
Open the link http://localhost:8080/index.html in say Chrome browser.
Using JSX
Let's add in-browser babel transformer by adding a script tag