Created
August 30, 2020 18:32
-
-
Save soker90/04a97b174d97bd9c154812e015f223c3 to your computer and use it in GitHub Desktop.
Hook for useEffect dependecy
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
import { useRef, useEffect } from 'react'; | |
const useIsMountedRef = () => { | |
const isMounted = useRef(true); | |
useEffect(() => () => { | |
isMounted.current = false; | |
}, []); | |
return isMounted; | |
} | |
export default useIsMountedRef; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment