Skip to content

Instantly share code, notes, and snippets.

View clintonmedbery's full-sized avatar

Clinton Medbery clintonmedbery

View GitHub Profile
@clintonmedbery
clintonmedbery / isMount.js
Last active February 4, 2020 05:37
Useful Hooks
//Hook used to determine if it is a component's first mount
//Useful to put in useEffect functions that share data calls but not all the same calls
import { useRef, useEffect } from 'react'
//https://stackoverflow.com/a/56267719/3058839
export const useIsMount = () => {
const isMountRef = useRef(true)
useEffect(() => {
isMountRef.current = false