react-use/docs/useRefMounted.md
2019-08-20 00:58:41 +03:00

29 lines
479 B
Markdown

# `useRefMounted`
>**DEPRECATED**
>This method is obsolete, use `useMountedState` instead.
Lifecycle hook that tracks if component is mounted. Returns a ref, which has a
boolean `.current` property.
## Usage
```jsx
import {useRefMounted} from 'react-use';
const Demo = () => {
const refMounted = useRefMounted();
useEffect(() => {
setTimeout(() => {
if (refMounted.current) {
// ...
} else {
// ...
}
}, 1000);
});
};
```