overleaf/services/web/frontend/js/shared/hooks/use-is-mounted.ts
ilkin-overleaf 5b0c122f5d Merge pull request #7290 from overleaf/ii-7154-list-user-emails
List of user emails

GitOrigin-RevId: 28a8e405812932ba7ebd8043a4dc9d3c573a68b2
2022-04-11 08:03:38 +00:00

14 lines
267 B
TypeScript

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