mirror of
https://github.com/streamich/react-use.git
synced 2025-12-08 18:02:14 +00:00
479 B
479 B
useRefMounted
DEPRECATED
This method is obsolete, useuseMountedStateinstead.
Lifecycle hook that tracks if component is mounted. Returns a ref, which has a
boolean .current property.
Usage
import {useRefMounted} from 'react-use';
const Demo = () => {
const refMounted = useRefMounted();
useEffect(() => {
setTimeout(() => {
if (refMounted.current) {
// ...
} else {
// ...
}
}, 1000);
});
};