import { useRef, useEffect } from "react"; /** * * @kind 06-Lifecycle */ export const useIsMounted = () => { const componentIsMounted = useRef(true); useEffect(() => { componentIsMounted.current = true; return () => { componentIsMounted.current = false; }; }, []); return componentIsMounted; };