File tree 1 file changed +12
-6
lines changed
examples/counter/src/components 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -2,19 +2,19 @@ import React, { Component } from 'react'
2
2
import PropTypes from 'prop-types'
3
3
4
4
class Counter extends Component {
5
- static propTypes = {
6
- value : PropTypes . number . isRequired ,
7
- onIncrement : PropTypes . func . isRequired ,
8
- onDecrement : PropTypes . func . isRequired
5
+ constructor ( props ) {
6
+ super ( props ) ;
7
+ this . incrementAsync = this . incrementAsync . bind ( this ) ;
8
+ this . incrementIfOdd = this . incrementIfOdd . bind ( this ) ;
9
9
}
10
10
11
- incrementIfOdd = ( ) => {
11
+ incrementIfOdd ( ) {
12
12
if ( this . props . value % 2 !== 0 ) {
13
13
this . props . onIncrement ( )
14
14
}
15
15
}
16
16
17
- incrementAsync = ( ) => {
17
+ incrementAsync ( ) {
18
18
setTimeout ( this . props . onIncrement , 1000 )
19
19
}
20
20
@@ -44,4 +44,10 @@ class Counter extends Component {
44
44
}
45
45
}
46
46
47
+ Counter . propTypes = {
48
+ value : PropTypes . number . isRequired ,
49
+ onIncrement : PropTypes . func . isRequired ,
50
+ onDecrement : PropTypes . func . isRequired
51
+ }
52
+
47
53
export default Counter
You can’t perform that action at this time.
0 commit comments