mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-25 07:52:59 +03:00
18 lines
323 B
TypeScript
18 lines
323 B
TypeScript
import { useCallback, useEffect, useRef } from 'react';
|
|
|
|
function useIsMounted() {
|
|
const isMounted = useRef(false);
|
|
|
|
useEffect(() => {
|
|
isMounted.current = true;
|
|
|
|
return () => {
|
|
isMounted.current = false;
|
|
};
|
|
}, []);
|
|
|
|
return useCallback(() => isMounted.current, []);
|
|
}
|
|
|
|
export default useIsMounted;
|