27 lines
377 B
JavaScript
27 lines
377 B
JavaScript
import React from 'react'
|
|
|
|
class Clock extends React.Component {
|
|
|
|
constructor(props) {
|
|
super(props)
|
|
this.state = {
|
|
time: new Date()
|
|
}
|
|
setInterval(this.tick.bind(this), 1000);
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<div>Time: { this.state.time.toString() }</div>
|
|
)
|
|
}
|
|
|
|
tick() {
|
|
this.setState({ time: new Date() });
|
|
}
|
|
|
|
}
|
|
|
|
|
|
export default Clock
|