overleaf/services/web/frontend/js/shared/hooks/use-is-mounted.js

14 lines
235 B
JavaScript
Raw Normal View History

import { useEffect, useRef } from 'react'
export default function useIsMounted() {
const isMounted = useRef(true)
useEffect(() => {
return () => {
isMounted.current = false
}
}, [isMounted])
return isMounted
}