Last active
August 31, 2020 23:55
-
-
Save criszelaya24/50a93f897527c404677a5914797b0532 to your computer and use it in GitHub Desktop.
componente temporizador por tiempo
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
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