Skip to content

Instantly share code, notes, and snippets.

@tpjnorton
Last active December 15, 2020 03:19
Show Gist options
  • Save tpjnorton/826a84525d86bb7c3c4e6187c62abdf5 to your computer and use it in GitHub Desktop.
Save tpjnorton/826a84525d86bb7c3c4e6187c62abdf5 to your computer and use it in GitHub Desktop.
const useMounted = () => {
const isMounted = useRef(false);
useEffect(() => {
isMounted.current = true;
return () => {
isMounted.current = false;
};
}, []);
return isMounted;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment