import React, { useState } from "react"; var ReactDOM = require("react-dom"); import Form from "./Form"; var isLoggedIn = false; const NEWDATE = new Date(); const nowDate = NEWDATE.toLocaleTimeString(); function App() { setInterval(getTime,1000); const [time, nextTime] = useState(nowDate); function getTime() { console.log("clicked"); console.log(new Date().toLocaleTimeString()) return nextTime(new Date().toLocaleTimeString()); } return ( <div className="container"> {isLoggedIn === true ? <h1>Hello Men</h1> : <Form />} <h1 className="timer">{time}</h1> <button className="timer" onClick={getTime}> Get Time </button> </div> ); } export default App;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter