This repository was archived by the owner on Aug 24, 2021. It is now read-only.
File tree 3 files changed +22
-18
lines changed
3 files changed +22
-18
lines changed Original file line number Diff line number Diff line change 3
3
< title > Todo App</ title >
4
4
</ head >
5
5
< body >
6
- < pre id ="approot "> </ pre >
6
+ < div id ="root "> </ div >
7
7
< script src ="/static/bundle.js "> </ script >
8
8
</ body >
9
9
</ html >
Original file line number Diff line number Diff line change 28
28
"babel-eslint" : " ^3.1.9" ,
29
29
"babel-loader" : " ^5.1.2" ,
30
30
"eslint-plugin-react" : " ^2.3.0" ,
31
- "mobservable-react-devtools" : " ^1 .0.0 " ,
31
+ "mobservable-react-devtools" : " ^2 .0.1 " ,
32
32
"react-hot-loader" : " ^1.2.7" ,
33
33
"webpack" : " ^1.9.6" ,
34
34
"webpack-dev-server" : " ^1.8.2"
35
35
},
36
36
"dependencies" : {
37
37
"mobservable" : " ^1.0.0" ,
38
- "mobservable-react" : " ^1 .0.0" ,
38
+ "mobservable-react" : " ^2 .0.0" ,
39
39
"react" : " ^0.14.0" ,
40
40
"react-dom" : " ^0.14.0"
41
41
}
Original file line number Diff line number Diff line change 1
- import React from 'react' ;
1
+ import React , { Component } from 'react' ;
2
+ import ReactDOM from 'react-dom' ;
2
3
import { observable } from 'mobservable' ;
3
4
import { observer } from 'mobservable-react' ;
4
5
5
6
// uncomment next line to enable the dev-tools.
6
- // import 'mobservable-react-devtools';
7
+ import 'mobservable-react-devtools' ;
7
8
8
- var appState = observable ( {
9
+ const appState = observable ( {
9
10
timer : 0
10
11
} ) ;
11
12
12
13
appState . resetTimer = function ( ) {
13
14
appState . timer = 0 ;
14
15
} ;
15
16
16
- setInterval ( function ( ) {
17
+ setInterval ( ( ) => {
17
18
appState . timer += 1 ;
18
19
} , 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 = ( ) => {
28
32
this . props . appState . resetTimer ( ) ;
29
33
}
30
- } ) ) ;
34
+ } ;
31
35
32
- React . render ( < TimerView appState = { appState } /> , document . body ) ;
36
+ ReactDOM . render ( < TimerView appState = { appState } /> , document . getElementById ( 'root' ) ) ;
You can’t perform that action at this time.
0 commit comments