Skip to content

Commit 7cc533f

Browse files
author
Eugene Cheung
committed
Updates, minor edits
1 parent b168cd5 commit 7cc533f

File tree

8 files changed

+33
-34
lines changed

8 files changed

+33
-34
lines changed

client/app/components/App/App.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React from 'react';
1+
import React, { Component, PropTypes } from 'react';
22

33
import Header from '../Header/Header';
44
import Footer from '../Footer/Footer';
55

6-
class App extends React.Component {
6+
class App extends Component {
77
static propTypes = {
8-
children: React.PropTypes.node
8+
children: PropTypes.node
99
};
1010

1111
constructor(props) {

client/app/components/Home/Home.js

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from 'react';
1+
import React, { Component } from 'react';
22
import 'whatwg-fetch';
33

4-
class Home extends React.Component {
4+
class Home extends Component {
55
constructor(props) {
66
super(props);
77

@@ -19,9 +19,8 @@ class Home extends React.Component {
1919

2020
componentDidMount() {
2121
fetch('/api/counters')
22-
.then((response) => {
23-
return response.json();
24-
}).then((json) => {
22+
.then(res => res.json())
23+
.then(json => {
2524
this.setState({
2625
counters: json
2726
});
@@ -30,10 +29,9 @@ class Home extends React.Component {
3029

3130
newCounter() {
3231
fetch('/api/counters', { method: 'POST' })
33-
.then((response) => {
34-
return response.json();
35-
}).then((json) => {
36-
var data = this.state.counters;
32+
.then(res => res.json())
33+
.then(json => {
34+
let data = this.state.counters;
3735
data.push(json);
3836

3937
this.setState({
@@ -46,9 +44,8 @@ class Home extends React.Component {
4644
const id = this.state.counters[index]._id;
4745

4846
fetch(`/api/counters/${id}/increment`, { method: 'PUT' })
49-
.then((response) => {
50-
return response.json();
51-
}).then((json) => {
47+
.then(res => res.json())
48+
.then(json => {
5249
this._modifyCounter(index, json);
5350
});
5451
}
@@ -57,9 +54,8 @@ class Home extends React.Component {
5754
const id = this.state.counters[index]._id;
5855

5956
fetch(`/api/counters/${id}/decrement`, { method: 'PUT' })
60-
.then((response) => {
61-
return response.json();
62-
}).then((json) => {
57+
.then(res => res.json())
58+
.then(json => {
6359
this._modifyCounter(index, json);
6460
});
6561
}
@@ -68,13 +64,13 @@ class Home extends React.Component {
6864
const id = this.state.counters[index]._id;
6965

7066
fetch(`/api/counters/${id}`, { method: 'DELETE' })
71-
.then((response) => {
67+
.then(_ => {
7268
this._modifyCounter(index, null);
7369
});
7470
}
7571

7672
_modifyCounter(index, data) {
77-
var prevData = this.state.counters;
73+
let prevData = this.state.counters;
7874

7975
if (data) {
8076
prevData[index] = data;

client/app/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Home from './components/Home/Home';
1313

1414
import HelloWorld from './components/HelloWorld/HelloWorld';
1515

16-
require('./styles/styles.scss');
16+
import './styles/styles.scss';
1717

1818
render((
1919
<Router history={browserHistory}>

config/webpack.common.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const webpack = require('webpack');
2-
const helpers = require('./helpers');
3-
42
const autoprefixer = require('autoprefixer');
53
const HtmlWebpackPlugin = require('html-webpack-plugin');
64
const ExtractTextPlugin = require('extract-text-webpack-plugin');
75

6+
const helpers = require('./helpers');
7+
88
const NODE_ENV = process.env.NODE_ENV;
99
const isProd = NODE_ENV === 'production';
1010

@@ -35,7 +35,7 @@ module.exports = {
3535
{
3636
test: /\.jsx?$/,
3737
include: helpers.root('client'),
38-
loader: 'babel-loader'
38+
loader: 'babel'
3939
},
4040

4141
// SCSS files

config/webpack.dev.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const webpack = require('webpack');
22
const merge = require('webpack-merge');
3+
34
const commonConfig = require('./webpack.common');
45

56
module.exports = merge(commonConfig, {

config/webpack.prod.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const webpack = require('webpack');
22
const merge = require('webpack-merge');
33
const CopyWebpackPlugin = require('copy-webpack-plugin');
4+
45
const helpers = require('./helpers');
56
const commonConfig = require('./webpack.common');
67

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@
1414
"start:prod": "NODE_ENV=production webpack --config ./webpack.config.js --progress --profile --colors && node server"
1515
},
1616
"dependencies": {
17-
"react": "^15.3.2",
18-
"react-dom": "^15.3.2",
17+
"react": "^15.4.0",
18+
"react-dom": "^15.4.0",
1919
"react-router": "^3.0.0",
20-
"whatwg-fetch": "^1.0.0"
20+
"whatwg-fetch": "^2.0.1"
2121
},
2222
"devDependencies": {
2323
"autoprefixer": "^6.5.3",
2424
"babel-core": "^6.18.2",
25-
"babel-loader": "^6.2.7",
26-
"babel-plugin-transform-class-properties": "^6.18.0",
25+
"babel-loader": "^6.2.8",
26+
"babel-plugin-transform-class-properties": "^6.19.0",
2727
"babel-polyfill": "^6.16.0",
2828
"babel-preset-es2015": "^6.18.0",
2929
"babel-preset-react": "^6.16.0",
3030
"body-parser": "^1.15.2",
3131
"connect-history-api-fallback": "^1.3.0",
3232
"copy-webpack-plugin": "^4.0.1",
33-
"css-loader": "^0.25.0",
33+
"css-loader": "^0.26.0",
3434
"express": "^4.14.0",
3535
"extract-text-webpack-plugin": "^1.0.1",
3636
"html-webpack-plugin": "^2.24.1",
37-
"mongoose": "^4.6.7",
38-
"node-sass": "^3.12.2",
37+
"mongoose": "^4.6.8",
38+
"node-sass": "^3.13.0",
3939
"nodemon": "^1.11.0",
4040
"postcss-loader": "^1.1.1",
4141
"react-hot-loader": "^3.0.0-beta.6",
@@ -44,6 +44,6 @@
4444
"webpack": "^1.13.3",
4545
"webpack-dev-middleware": "^1.8.4",
4646
"webpack-hot-middleware": "^2.13.2",
47-
"webpack-merge": "^0.16.0"
47+
"webpack-merge": "^0.17.0"
4848
}
4949
}

server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ nodemon({
99
ignore: [],
1010
watch: process.env.NODE_ENV !== 'production' ? ['server/*'] : false,
1111
ext: 'js'
12-
}).on('restart', function() {
12+
})
13+
.on('restart', function() {
1314
console.log('Server restarted!');
1415
})
1516
.once('exit', function () {

0 commit comments

Comments
 (0)