https://github.com/technote-space/use-unmount-ref
https://github.com/technote-space/use-unmount-ref
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/technote-space/use-unmount-ref
- Owner: technote-space
- License: mit
- Created: 2021-03-02T08:15:04.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-02-19T10:14:21.000Z (almost 3 years ago)
- Last Synced: 2025-06-05T14:46:56.928Z (6 months ago)
- Language: TypeScript
- Size: 1.53 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# useUnmountRef
[](https://badge.fury.io/js/%40technote-space%2Fuse-unmount-ref)
[](https://github.com/technote-space/use-unmount-ref/actions)
[](https://codecov.io/gh/technote-space/use-unmount-ref)
[](https://www.codefactor.io/repository/github/technote-space/use-unmount-ref)
[](https://github.com/technote-space/use-unmount-ref/blob/master/LICENSE)
React hook to handle unmount ref.
## Table of Contents
Details
- [Usage](#usage)
- [Install](#install)
- [Use](#use)
- [Author](#author)
## Usage
### Install
`yarn add @technote-space/use-unmount-ref`
or
`npm i @technote-space/use-unmount-ref`
### Use
e.g.
```tsx
import type { FC } from 'react';
import { useEffect, useState } from 'react';
import useUnmountRef from '@technote-space/use-unmount-ref';
const TestPage: FC = () => {
const unmountRef = useUnmountRef();
const [isLoading, setIsLoading] = useState(false);
useEffect(() => {
setIsLoading(true);
setTimeout(() => {
if(!unmountRef.current) {
setIsLoading(false);
}
}, 1000);
}, []);
return
{isLoading ? 'Loading...' : 'Not loading.'}
};
```
## Author
[GitHub (Technote)](https://github.com/technote-space)
[Blog](https://technote.space)