Update snippets/Timer.md

Co-Authored-By: arjunmahishi <arjun.mahishi@gmail.com>
This commit is contained in:
Robert Mennell
2018-12-30 18:12:39 +05:30
committed by GitHub
parent 95d01fee15
commit 18a92d1c24

View File

@ -20,7 +20,7 @@ class Timer extends Component {
this.reset()
this.interval = setInterval(() => {
if (this.state.timer < this.props.time) {
this.setState({timer: this.state.timer + 1})
this.setState(({ timer }) => ({timer: timer + 1}))
}else{
clearInterval(this.interval)
}