[examples] Update basic-commonjs for new React, watchify

This commit is contained in:
Paul O’Shannessy 2015-09-18 18:24:53 -07:00
parent f1ede3e6d2
commit 145ca279f9
4 changed files with 12 additions and 8 deletions

View File

@ -2,6 +2,8 @@
Run `npm install` in the directory to install React from npm. Then run: Run `npm install` in the directory to install React from npm. Then run:
./node_modules/.bin/browserify --debug --transform reactify ./index.js > ./bundle.js ```sh
npm start
```
to produce `bundle.js` with example code and React. to produce `bundle.js` with example code and React.

View File

@ -19,7 +19,7 @@
</div> </div>
<h4>Example Details</h4> <h4>Example Details</h4>
<p>This is written with JSX in a CommonJS module and precompiled to vanilla JS by running:</p> <p>This is written with JSX in a CommonJS module and precompiled to vanilla JS by running:</p>
<pre>browserify --debug --transform reactify index.js &gt; bundle.js</pre> <pre>npm start</pre>
<p> <p>
Learn more about React at Learn more about React at
<a href="https://facebook.github.io/react" target="_blank">facebook.github.io/react</a>. <a href="https://facebook.github.io/react" target="_blank">facebook.github.io/react</a>.

View File

@ -1,6 +1,7 @@
'use strict'; 'use strict';
var React = require('react'); var React = require('react');
var ReactDOM = require('react-dom');
var ExampleApplication = React.createClass({ var ExampleApplication = React.createClass({
render: function() { render: function() {
@ -16,7 +17,7 @@ var ExampleApplication = React.createClass({
var start = new Date().getTime(); var start = new Date().getTime();
setInterval(function() { setInterval(function() {
React.render( ReactDOM.render(
<ExampleApplication elapsed={new Date().getTime() - start} />, <ExampleApplication elapsed={new Date().getTime() - start} />,
document.getElementById('container') document.getElementById('container')
); );

View File

@ -2,12 +2,13 @@
"name": "react-basic-commonjs-example", "name": "react-basic-commonjs-example",
"description": "Basic example of using React with CommonJS", "description": "Basic example of using React with CommonJS",
"main": "index.js", "main": "index.js",
"devDependencies": { "dependencies": {
"browserify": "^6.3.3", "babelify": "^6.3.0",
"react": "^0.13.0", "react": "^0.14.0-rc1",
"reactify": "^0.17.1" "react-dom": "^0.14.0-rc1",
"watchify": "^3.4.0"
}, },
"scripts": { "scripts": {
"build": "browserify --debug --transform reactify index.js > bundle.js" "start": "watchify index.js -v -t babelify -o bundle.js"
} }
} }