Skip to content

Instantly share code, notes, and snippets.

@sgwilym
Created February 12, 2019 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgwilym/c6704dfde10a07815dcd7fec1d51f28f to your computer and use it in GitHub Desktop.
Save sgwilym/c6704dfde10a07815dcd7fec1d51f28f to your computer and use it in GitHub Desktop.
useIsMounted hook
let useIsMounted = () => {
let isMountedRef = useRef(false);
useEffect(() => {
isMountedRef.current = true;
}, [])
return isMountedRef.current;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment