Last active
April 20, 2021 11:50
-
-
Save prdxs/19377cab6b4d75429729a7d7e1600ed6 to your computer and use it in GitHub Desktop.
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({ className, style }) { | |
const [time, setTime] = useState(new Date().toLocaleTimeString()); | |
useEffect(() => { | |
setInterval(() => { | |
setTime(new Date().toLocaleTimeString()); | |
}, 1000); | |
}, []); | |
return ( | |
<span | |
className={clsx('Clock', className)} | |
style={style} | |
> | |
{time} | |
</span> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment