Created
February 2, 2020 08:38
-
-
Save simbathesailor/5f358866dba926d5cc504e9a601e7393 to your computer and use it in GitHub Desktop.
useisMountedRefUsage.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
function App() { | |
const isMountedRefApproach = useIsMountedRef(); | |
React.useEffect(() => { | |
if (isMountedRefApproach.current) { | |
console.log("I am mounted"); | |
} | |
}, [isMountedRefApproach.current]); | |
React.useEffect(() => { | |
console.log("parent"); | |
}, []); | |
console.log("isMountedRefApproach.current", isMountedRefApproach.current); | |
return ( | |
<div> | |
<Child /> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment