I hereby claim:
- I am ndudar on github.
- I am ndudar (https://keybase.io/ndudar) on keybase.
- I have a public key ASDtaO-VAhxUGfnT6zIWetZW5HUsGk2ComRS6bi3EtI5ggo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
//here's an example of how to use the Timer component: | |
import Timer from "./Timer"; | |
const App = () => { | |
return ( | |
<> | |
//this timer will count down from 3 minutes using the custom useTimer Hook | |
<Timer targetTimeMins={3}/> | |
</> |
//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 |
import { useEffect, useState } from 'react'; | |
//when I use this Hook, I will give it the timer target time in minutes | |
const useTimer = ({targetTimeMins}) => { | |
//minutes are converted to milliseconds | |
const targetTimeMS = targetTimeMins * 60 * 1000 | |
import React, { useState, useEffect } from "react" | |
const useMyCustomHook = (param) => { | |
const[data, setData] = useState(null) | |
useEffect(() => { | |
useEffect logic | |
}, [param]) | |
return { data } |
import React from "react" | |
import useMyCustomHook from "../utils/myCustomHook" | |
const Component = () => { | |
const { data } = useMyCustomHook(param) | |
return ( | |
JSX that references data | |
) | |
} |