mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
15 lines
316 B
TypeScript
15 lines
316 B
TypeScript
import { useCallback, useEffect, useRef } from 'react'
|
|
|
|
export function useIsMounted(): () => boolean {
|
|
const isMountedRef = useRef(true)
|
|
const isMounted = useCallback(() => isMountedRef.current, [])
|
|
|
|
useEffect(() => {
|
|
return () => {
|
|
isMountedRef.current = false
|
|
}
|
|
}, [])
|
|
|
|
return isMounted
|
|
}
|