use-unmount-ref 0.1.32
Install from the command line:
Learn more about npm packages
$ npm install @technote-space/use-unmount-ref@0.1.32
Install via package.json:
"@technote-space/use-unmount-ref": "0.1.32"
About this version
React hook to handle unmount ref.
yarn add @technote-space/use-unmount-ref
or
npm i @technote-space/use-unmount-ref
e.g.
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 <div>
{isLoading ? 'Loading...' : 'Not loading.'}
</div>
};