Welcome aboard! We are happy you are here and wish you good net-raft!
<html lang = "en">
<head>
<meta charset = "UTF-8">
<title>React App</title>
<script src="https://fb.me/react-0.14.3.min.js"></script>
<script src="https://fb.me/react-dom-0.14.3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script>
</head>
<body>
<script type="text/babel">
function checkTime(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}
class App extends React.Component {
constructor(...args) {
super(...args);
this.state = {
date: ``
};
}
startTime() {
const today = new Date();
const h = today.getHours();
const m = checkTime(today.getMinutes());
const s = checkTime(today.getSeconds());
this.setState({ date: h + ":" + m + ":" + s });
this.timeout = setTimeout(() => this.startTime(), 500);
}
componentDidMount() {
this.startTime();
}
componentWillUnmount() {
if (!this.timeout) return;
clearTimeout(this.timeout);
}
render() {
return <h1>{this.state.date}</h1>;
}
}
ReactDOM.render(
<App />,
document.getElementById('root')
);
</script>
<div id="root"></div>
</body>
</html>
The most helpful REACT solutions
How to get client ip address using react ?REACT
Click to see more ...
19.6K
421
how to get the type of a device using react ?REACT
Click to see more ...
2.4K
220
create digital clock reactREACT
Click to see more ...
1.8K
141
country dropdown using reactREACT
Click to see more ...
1.4K
127
create alarm clock using reactREACT
Click to see more ...
5.4K
115
How to get latitude and longitude using react/javascript ?REACT
Click to see more ...
1.1K
108
get client country reactREACT
Click to see more ...
933
82
get ip address reactREACT
Click to see more ...
1.2K
81
time ago reactREACT
Click to see more ...
744
74
detect mobile device reactREACT
Click to see more ...
707
58