Last active
September 28, 2019 07:14
-
-
Save christianwish/0d0f097061b2bd3a9e4fe89d6f52eca8 to your computer and use it in GitHub Desktop.
REact custom hook "useIsMounted"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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