Skip to content

Instantly share code, notes, and snippets.

@twhite96
Created January 5, 2019 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twhite96/ddc0617874f95a420c1b0d48da814877 to your computer and use it in GitHub Desktop.
Save twhite96/ddc0617874f95a420c1b0d48da814877 to your computer and use it in GitHub Desktop.
Stopwatch Bug 1
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