authelia/web/src/hooks/Mounted.ts

13 lines
290 B
TypeScript

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