Created
February 15, 2023 21:52
-
-
Save ndudar/a5f2a318f5ab5f7e335b685c2017e5d8 to your computer and use it in GitHub Desktop.
Timer.js
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 the useTimer Hook from the appropriate file path | |
import { useTimer } from "./useTimer"; | |
const Timer = (targetTimeMins) => { | |
//useTimer is invoked to get back the time remaining in minutes and seconds | |
const [minutes, seconds] = useTimer(targetTimeMins); | |
if (minutes + seconds <= 0) { | |
//if there is no time remaining, a component renders to say the time is up | |
return <ExpiredNotice />; | |
} else { | |
//otherwise the visual component of the timer is rendered, taking in the minutes and seconds as props | |
return <ShowTimer minutes={minutes} seconds={seconds} />; | |
} | |
}; | |
export default Timer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment