mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-14 20:40:17 -05:00
15 lines
267 B
TypeScript
15 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
|
||
|
}
|