Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
useisMountedRefUsage.jsx
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