Skip to content

Commit

Permalink
Moved propTypes checking, fixed undefined error (#2464)
Browse files Browse the repository at this point in the history
  • Loading branch information
krizzu authored and timdorr committed Jun 21, 2017
1 parent 689c800 commit 9e5feb2
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions examples/counter/src/components/Counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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

0 comments on commit 9e5feb2

Please sign in to comment.