authelia/web/src/hooks/Mounted.ts

10 lines
268 B
TypeScript

import { useRef, useEffect } from "react";
export function useIsMountedRef() {
const isMountedRef = useRef(false);
useEffect(() => {
isMountedRef.current = true;
return () => { isMountedRef.current = false };
});
return isMountedRef;
}