All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hooks.mounted.js Maven / Gradle / Ivy

There is a newer version: 0.80.3
Show newest version
import { useRef, useEffect } from 'react';

export function useMountedRef() {
  const ref = useRef(false);

  useEffect(() => {
    ref.current = true;
    return () => ref.current = false;
  }, []);

  return {ref, isMounted: () => ref.current}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy