Skip to content

Commit 2d73916

Browse files
committed
Initial commit
0 parents  commit 2d73916

File tree

9 files changed

+240
-0
lines changed

9 files changed

+240
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.DS_Store

.jshintrc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"bitwise": true,
3+
"browser": true,
4+
"camelcase": false,
5+
"curly": true,
6+
"eqeqeq": true,
7+
"esnext": true,
8+
"immed": true,
9+
"indent": 4,
10+
"latedef": false,
11+
"newcap": true,
12+
"noarg": true,
13+
"node": true,
14+
"quotmark": "single",
15+
"strict": true,
16+
"trailing": true,
17+
"undef": true,
18+
"unused": true,
19+
"sub": true,
20+
"globals": {
21+
"window": true
22+
}
23+
}

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# react-hot-starter
2+
3+
Hot starting point for React demos. Heavily based on [react-hot-loader](https://github.com/gaearon/react-hot-loader).
4+
5+
## Usage
6+
7+
1. npm install
8+
2. npm start
9+
3. Surf to `http://localhost:8080/webpack-dev-server/bundle`
10+
4. Code like mad
11+
5. ???
12+
6. Profit
13+
14+
## License
15+
16+
MIT (http://www.opensource.org/licenses/mit-license.php)

notes.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
## webpack
2+
3+
https://github.com/petehunt/webpack-howto
4+
5+
http://webpack.github.io/
6+
7+
http://localhost:8080/webpack-dev-server/bundle
8+
9+
* async loading
10+
* multiple entrypoints (bundles) - big one!
11+
12+
## React
13+
14+
https://github.com/enaqx/awesome-react
15+
16+
state (internal! access through this.state, this.setState to mutate)
17+
vs.
18+
properties (html attrs! access through this.props)
19+
20+
var oboe = require('oboe');
21+
22+
* getInitialState, getDefaultProps
23+
* componentDidMount
24+
25+
## Kryptoradio
26+
27+
* API http://localhost:3000/api/resource/exchange/jsoncsv
28+
29+
## Oboe
30+
31+
http://oboejs.com/
32+
33+
oboe('http://localhost:3000/api/resource/exchange/jsoncsv')
34+
.node('*', function(arr) {
35+
if(Array.isArray(arr) && Array.isArray(arr[0])) {
36+
arr = arr[0];
37+
38+
var actionType = arr[3];
39+
var priceLevel = parseFloat(arr[4]);
40+
var amount = parseFloat(arr[5]);
41+
amount = isNaN(amount)? 0: amount;
42+
43+
var o = {
44+
marketName: arr[0],
45+
securityName: arr[1],
46+
currency: arr[2],
47+
actionType: actionType,
48+
priceLevel: priceLevel,
49+
amount: amount
50+
};
51+
52+
that.setState({
53+
exchanges: that.state.exchanges.concat([o])
54+
});
55+
56+
...
57+
}
58+
});
59+
60+
## D3
61+
62+
http://square.github.io/intro-to-d3/

package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "react-hot-starter",
3+
"version": "0.2.5",
4+
"description": "Hot starting point for React apps",
5+
"scripts": {
6+
"start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --hot"
7+
},
8+
"directories": {
9+
"src": "src"
10+
},
11+
"dependencies": {
12+
"jsx-loader": "0.12.0",
13+
"react": "0.12.0",
14+
"react-hot-loader": "0.5.0",
15+
"webpack": "1.4.9",
16+
"webpack-dev-server": "1.6.5"
17+
},
18+
"keywords": [
19+
"react",
20+
"webpack",
21+
"hmr",
22+
"livereload"
23+
],
24+
"author": "Juho Vepsalainen <[email protected]>",
25+
"license": "MIT"
26+
}

src/a.jsx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/** @jsx React.DOM */
2+
3+
var React = require('react'),
4+
B = require('./b');
5+
6+
var A = React.createClass({
7+
getInitialState: function () {
8+
return {
9+
number: Math.round(Math.random() * 100)
10+
};
11+
},
12+
13+
componentWillMount: function () {
14+
this._intervalHandle = window.setInterval(this.incrementNumber, 1000);
15+
},
16+
17+
componentWillUnmount: function () {
18+
window.clearInterval(this._intervalHandle);
19+
window.alert('Unmounting parent');
20+
},
21+
22+
incrementNumber: function () {
23+
this.setState({
24+
number: this.state.number + 1
25+
});
26+
},
27+
28+
render: function() {
29+
return (
30+
<div>
31+
<p>Open an editor, edit and save <code>example/a.jsx</code>.</p>
32+
<p><b>The number should keep incrementing one by one.</b></p>
33+
34+
{this.renderStuff()}
35+
36+
<p>This should also work for children:</p>
37+
<B />
38+
</div>
39+
);
40+
},
41+
42+
renderStuff: function () {
43+
return (
44+
<div>
45+
<input type='text' value={this.state.number} />
46+
<button onClick={this.incrementNumber}>Increment by one</button>
47+
</div>
48+
);
49+
}
50+
});
51+
52+
module.exports = A;

src/app.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/** @jsx React.DOM */
2+
3+
var React = require('react'),
4+
A = require('./a');
5+
6+
React.renderComponent(<A />, document.body);

src/b.jsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/** @jsx React.DOM */
2+
3+
var React = require('react');
4+
5+
var B = React.createClass({
6+
render: function() {
7+
return (
8+
<div style={{background: 'purple', color: 'white'}}>
9+
<p>I am <code>example/b.jsx</code>, feel free to edit me.</p>
10+
<img src='http://facebook.github.io/react/img/logo_og.png' width='200' />
11+
<br />
12+
<C />
13+
</div>
14+
);
15+
},
16+
17+
componentWillUnmount: function () {
18+
window.alert('Unmounting child');
19+
}
20+
});
21+
22+
var C = React.createClass({
23+
render: function () {
24+
return <span>This should also work for multiple components in the same file.</span>;
25+
}
26+
});
27+
28+
module.exports = B;

webpack.config.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
var path = require('path');
3+
4+
var webpack = require('webpack');
5+
6+
7+
module.exports = {
8+
entry: ['webpack/hot/dev-server', './src/app'],
9+
devtool: 'source-map',
10+
output: {
11+
path: path.join(__dirname, 'output'),
12+
filename: 'bundle.js'
13+
},
14+
resolveLoader: {
15+
modulesDirectories: ['src', 'node_modules']
16+
},
17+
resolve: {
18+
extensions: ['', '.jsx', '.js']
19+
},
20+
module: {
21+
loaders: [
22+
{ test: /\.jsx$/, loaders: ['react-hot', 'jsx'] }
23+
]
24+
}
25+
};

0 commit comments

Comments
 (0)