Skip to content

Instantly share code, notes, and snippets.

@christianwish
Last active September 28, 2019 07:14
Show Gist options
  • Save christianwish/0d0f097061b2bd3a9e4fe89d6f52eca8 to your computer and use it in GitHub Desktop.
Save christianwish/0d0f097061b2bd3a9e4fe89d6f52eca8 to your computer and use it in GitHub Desktop.
REact custom hook "useIsMounted"
import * as React from 'react';
export const useIsMounted = (): boolean => {
const [isMounted, setIsMounted] = React.useState(false);
React.useEffect(() => setIsMounted(true), []);
return isMounted;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment