function useIsMounted() {
  const state = React.useRef(true);

  React.useEffect(() => {
    return () => state.current = false;
  }, []);

  return React.useCallback(() => state.current, []);
}
/**
 * Determine if a component is currently mounted.
 * Use this in instances where you need to ensure that async
 * actions only happen while a component is mounted and
 * you are unable to cancel those async actions on unount.
 * It is preferred to cancel an async work started by your
 * component if possible.
 */
Determine if a component is currently mounted.
Use this in instances where you need to ensure that async
actions only happen while a component is mounted and
you are unable to cancel those async actions on unount.
It is preferred to cancel an async work started by your
component if possible.
Determine if a component is currently mounted . Use this in instances where you need to ensure that async actions only happen while a component is mounted and you are unable to cancel those async actions on unount . It is preferred to cancel an async work started by your component if possible .
function useIsMounted() {
  const state = React.useRef(true);
  React.useEffect(() => {
    return () => state.current = false;
  }, []);
  return React.useCallback(() => state.current, []);
}
function useIsMounted ( ) { const state = React . useRef ( true ) ; React . useEffect ( ( ) => { return ( ) => state . current = false ; } , [ ] ) ; return React . useCallback ( ( ) => state . current , [ ] ) ; }
Determine if a component is currently mounted.
Determine if a component is currently mounted .