Created
December 28, 2016 07:44
-
-
Save nayunhwan/18d2c2d25963a3dc68ec13dc45a0912d to your computer and use it in GitHub Desktop.
React Example TickingClock with Comopnent
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
function Clock(props) { | |
return ( | |
<div> | |
<h1>Hello, world!</h1> | |
<h2>It is {props.date.toLocaleTimeString()}.</h2> | |
</div> | |
); | |
} | |
function tick() { | |
ReactDOM.render( | |
<Clock date={new Date()} />, | |
document.getElementById('root') | |
); | |
} | |
setInterval(tick, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment