Last active
February 2, 2020 08:36
-
-
Save simbathesailor/2e6a17f1f9423b058e0e006e8e8a88be to your computer and use it in GitHub Desktop.
useIsMountedRef.jsx
This file contains 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
const useIsMountedRef = () => { | |
const isMounted = React.useRef(false); | |
React.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