Skip to content

Instantly share code, notes, and snippets.

@prdxs
Last active April 20, 2021 11:50
Show Gist options
  • Save prdxs/19377cab6b4d75429729a7d7e1600ed6 to your computer and use it in GitHub Desktop.
Save prdxs/19377cab6b4d75429729a7d7e1600ed6 to your computer and use it in GitHub Desktop.
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