UNPKG

wix-style-react

Version:
15 lines 494 B
import { useRef, useEffect } from 'react'; // Returns a function that checks whether component is still mounted const useIsMounted = () => { const mountedRef = useRef(true); useEffect(() => { // React performs the cleanup when the component unmounts const cleanup = () => { mountedRef.current = false; }; return cleanup; }, []); return () => mountedRef.current; }; export default useIsMounted; //# sourceMappingURL=useIsMounted.js.map