RedHatInsights/insights-rbac-ui

View on GitHub
src/hooks/useIsMounted.js

Summary

Maintainability
A
0 mins
Test Coverage
import { useEffect, useRef } from 'react';

const useIsMounted = () => {
  const isMounted = useRef(false);
  useEffect(() => {
    isMounted.current = true;
    return () => {
      isMounted.current = false;
    };
  }, []);
  return isMounted;
};

export default useIsMounted;