Created
July 19, 2018 10:46
-
-
Save noblesilence/f27baef6beda6edf8a6569cbb925b8fd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import React, { Component } from "react"; | |
import "./App.css"; | |
import EasyTimer from "easytimer"; | |
class App extends Component { | |
constructor() { | |
super(); | |
this.state = { timer: null, timeValues: "" }; | |
} | |
componentDidMount() { | |
let timer = new EasyTimer(); | |
this.setState({ timer: timer }); | |
timer.start(); | |
timer.addEventListener("secondsUpdated", this.tick); | |
} | |
tick() { | |
const { timer } = this.state; | |
const timeValues = timer.getTimeValues().toString(); | |
this.setState({ timeValues: timeValues }); | |
console.log(`timer: ${timer}`); | |
} | |
render() { | |
return <div className="App">{this.state.timeValues}</div>; | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment