wix-style-react
Version:
wix-style-react
15 lines • 494 B
JavaScript
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