Created
January 5, 2019 06:11
-
-
Save twhite96/ddc0617874f95a420c1b0d48da814877 to your computer and use it in GitHub Desktop.
Stopwatch Bug 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StopWatch extends React.Component { | |
state = { lapse: 0, running: false }; | |
handleRunClick = () => { | |
const startTime = Date.now() - this.state.lapse; | |
setInterval(() => { | |
this.setState({ | |
lapse: Date.now - startTime | |
}); | |
}); | |
this.setState({ | |
running: true | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment