Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
React Example TickingClock with Comopnent
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