UNPKG

@churchapps/apphelper

Version:

Library of helper functions for React and NextJS ChurchApps

17 lines (12 loc) 350 B
import { useEffect, useRef, useCallback } from "react"; export const useMountedState = () => { const mountedRef = useRef(false) const isMounted = useCallback(() => mountedRef.current, []) useEffect(() => { mountedRef.current = true return () => { mountedRef.current = false } }, []) return isMounted }