Skip to content

Instantly share code, notes, and snippets.

View ndudar's full-sized avatar

Natalie Dudar ndudar

View GitHub Profile
@ndudar
ndudar / keybase.md
Last active July 17, 2023 15:58
keybase.md

Keybase proof

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:

@ndudar
ndudar / using the timer
Created February 15, 2023 22:04
Using Timer
//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}/>
</>
@ndudar
ndudar / Timer Custom Hook
Created February 15, 2023 21:52
Timer.js
//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
@ndudar
ndudar / useTimer
Created February 14, 2023 21:30
useTimer Custom Hook
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
@ndudar
ndudar / React-Custom-Hooks-Pseudo-Hook
Last active February 14, 2023 21:23
Pseudocode for the custom Hook
import React, { useState, useEffect } from "react"
const useMyCustomHook = (param) => {
const[data, setData] = useState(null)
useEffect(() => {
useEffect logic
}, [param])
return { data }
@ndudar
ndudar / React-Custom-Hooks-Pseudo-App
Last active February 14, 2023 21:24
Pseudocode for the App.js
import React from "react"
import useMyCustomHook from "../utils/myCustomHook"
const Component = () => {
const { data } = useMyCustomHook(param)
return (
JSX that references data
)
}