mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-25 06:30:00 +05:30
af59cc033f
Convert more components from class components to functional. Fix invalid finish state when client was auto approved
18 lines
547 B
TypeScript
18 lines
547 B
TypeScript
import { useCallback, useEffect, useRef } from 'react';
|
|
|
|
// This code is copied from the usehooks-ts: https://usehooks-ts.com/react-hook/use-is-mounted
|
|
// Replace it with the library when the Node.js version of the project will be updated at least to 16.
|
|
export default function useIsMounted(): () => boolean {
|
|
const isMounted = useRef(false);
|
|
|
|
useEffect(() => {
|
|
isMounted.current = true;
|
|
|
|
return () => {
|
|
isMounted.current = false;
|
|
};
|
|
}, []);
|
|
|
|
return useCallback(() => isMounted.current, []);
|
|
}
|