Skip to content
This repository was archived by the owner on Aug 24, 2021. It is now read-only.

Commit 64f47f1

Browse files
committed
updated dependencies, use ES6 syntax
1 parent 761d036 commit 64f47f1

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<title>Todo App</title>
44
</head>
55
<body>
6-
<pre id="approot"></pre>
6+
<div id="root"></div>
77
<script src="/static/bundle.js"></script>
88
</body>
99
</html>

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
"babel-eslint": "^3.1.9",
2929
"babel-loader": "^5.1.2",
3030
"eslint-plugin-react": "^2.3.0",
31-
"mobservable-react-devtools": "^1.0.0",
31+
"mobservable-react-devtools": "^2.0.1",
3232
"react-hot-loader": "^1.2.7",
3333
"webpack": "^1.9.6",
3434
"webpack-dev-server": "^1.8.2"
3535
},
3636
"dependencies": {
3737
"mobservable": "^1.0.0",
38-
"mobservable-react": "^1.0.0",
38+
"mobservable-react": "^2.0.0",
3939
"react": "^0.14.0",
4040
"react-dom": "^0.14.0"
4141
}

src/index.js

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,36 @@
1-
import React from 'react';
1+
import React, {Component} from 'react';
2+
import ReactDOM from 'react-dom';
23
import {observable} from 'mobservable';
34
import {observer} from 'mobservable-react';
45

56
// uncomment next line to enable the dev-tools.
6-
// import 'mobservable-react-devtools';
7+
import 'mobservable-react-devtools';
78

8-
var appState = observable({
9+
const appState = observable({
910
timer: 0
1011
});
1112

1213
appState.resetTimer = function() {
1314
appState.timer = 0;
1415
};
1516

16-
setInterval(function() {
17+
setInterval(() => {
1718
appState.timer += 1;
1819
}, 1000);
19-
20-
var TimerView = observer(React.createClass({
21-
render: function() {
22-
return (<button onClick={this.onReset}>
23-
Seconds passed: {this.props.appState.timer}
24-
</button>);
25-
},
26-
27-
onReset: function() {
20+
21+
@observer
22+
class TimerView extends Component {
23+
render() {
24+
return (
25+
<button onClick={this.onReset}>
26+
Seconds passed: {this.props.appState.timer}
27+
</button>
28+
);
29+
}
30+
31+
onReset = () => {
2832
this.props.appState.resetTimer();
2933
}
30-
}));
34+
};
3135

32-
React.render(<TimerView appState={appState} />, document.body);
36+
ReactDOM.render(<TimerView appState={appState} />, document.getElementById('root'));

0 commit comments

Comments
 (0)