REACT create digital clock react - Net-Raft.com

Welcome aboard! We are happy you are here and wish you good net-raft!




Just a Web Code Solution

create digital clock react


 1209

Show ResultREACT


2

<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>


By     Created   
The power of the user (%)
13%



The most helpful REACT solutions

How to get client ip address using react ?How to get client ip address using react ?REACT

Click to see more ...

  10.4K     421

how to get the type of a device using react ?how to get the type of a device using react ?REACT

Click to see more ...

  1.8K     214

create digital clock reactcreate digital clock reactREACT

Click to see more ...

  1.2K     141

country dropdown using reactcountry dropdown using reactREACT

Click to see more ...

  936     127

How to get latitude and longitude using react/javascript ?How to get latitude and longitude using react/javascript ?REACT

Click to see more ...

  805     108

create alarm clock using reactcreate alarm clock using reactREACT

Click to see more ...

  3.1K     84

get client country reactget client country reactREACT

Click to see more ...

  527     82

get ip address reactget ip address reactREACT

Click to see more ...

  612     80

time ago reacttime ago reactREACT

Click to see more ...

  396     74

detect mobile device reactdetect mobile device reactREACT

Click to see more ...

  376     58