Last active
December 16, 2016 22:41
-
-
Save joemsak/9684c3e17118767bc4c9c3593a8f1682 to your computer and use it in GitHub Desktop.
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
import React, { Component } from 'react'; | |
import moment from 'moment'; | |
class Clock extends Component { | |
constructor() { | |
super() | |
this.state = { | |
formattedDateTime: moment().format('MMMM Do YYYY, h:mm:ss a'), | |
}; | |
} | |
tick() { | |
this.setState({ | |
formattedDateTime: moment().format('MMMM Do YYYY, h:mm:ss a'), | |
}); | |
} | |
render() { | |
setTimeout(this.tick.bind(this), 0); | |
return ( | |
<div className="clock"> | |
{this.state.formattedDateTime} | |
</div> | |
) | |
} | |
} | |
export default Clock; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment