UNPKG

globalbridge-lsf-custom

Version:

GlobalBridge in-house labeling tool, originating from LSF.

22 lines (17 loc) • 420 B
import { useEffect, useRef } from 'react'; /** * Protects async tasks from causing memory leaks in other effects/callbacks. * Wrap any set states within a component with * * if (mounted.current) { ... } */ export const useMounted = () => { const mounted = useRef(true); useEffect(() => { mounted.current = true; return () => { mounted.current = false; }; }, []); return mounted; };