Skip to content

Instantly share code, notes, and snippets.

@criszelaya24
Last active August 31, 2020 23:55
Show Gist options
  • Save criszelaya24/50a93f897527c404677a5914797b0532 to your computer and use it in GitHub Desktop.
Save criszelaya24/50a93f897527c404677a5914797b0532 to your computer and use it in GitHub Desktop.
componente temporizador por tiempo
import React, { useState } from 'react';
const UpdateTimeBy = (props) => {
const today = new Date();
const updateTime = () => {
return `${today.getHours()} : ${today.getMinutes()} : ${today.getSeconds()}`;
}
const [time, setTime] = useState(updateTime())
setTimeout(() => {
setTime(updateTime())
}, props.seconds || 1000);
return(
<div>
<h1>{time}</h1>
</div>
)
};
export default UpdateTimeBy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment