diff --git a/examples/counter/src/components/Counter.js b/examples/counter/src/components/Counter.js index 344a7d9d71..052f02bf07 100644 --- a/examples/counter/src/components/Counter.js +++ b/examples/counter/src/components/Counter.js @@ -2,19 +2,19 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' class Counter extends Component { - static propTypes = { - value: PropTypes.number.isRequired, - onIncrement: PropTypes.func.isRequired, - onDecrement: PropTypes.func.isRequired + constructor(props) { + super(props); + this.incrementAsync = this.incrementAsync.bind(this); + this.incrementIfOdd = this.incrementIfOdd.bind(this); } - incrementIfOdd = () => { + incrementIfOdd() { if (this.props.value % 2 !== 0) { this.props.onIncrement() } } - incrementAsync = () => { + incrementAsync() { setTimeout(this.props.onIncrement, 1000) } @@ -44,4 +44,10 @@ class Counter extends Component { } } +Counter.propTypes = { + value: PropTypes.number.isRequired, + onIncrement: PropTypes.func.isRequired, + onDecrement: PropTypes.func.isRequired +} + export default Counter