# extendify/1.17.1/src/Library/hooks/useIsMounted.js

Extendify, version 1.17.1. 21 lines.

- Page: https://pluginprobe.com/plugins/extendify/1.17.1/code/src/Library/hooks/useIsMounted.js
- Raw: https://pluginprobe.com/plugins/extendify/1.17.1/raw/src/Library/hooks/useIsMounted.js
- Modified: 2023-10-11T02:07:34+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/1.17.1/code/src/Library/hooks/useIsMounted.js#L10-L20`.

```javascript
import { useRef, useEffect, useLayoutEffect } from '@wordpress/element';

export const useIsMounted = () => {
	const isMounted = useRef(false);

	useEffect(() => {
		isMounted.current = true;
		return () => (isMounted.current = false);
	});
	return isMounted;
};
export const useIsMountedLayout = () => {
	const isMounted = useRef(false);

	useLayoutEffect(() => {
		isMounted.current = true;
		return () => (isMounted.current = false);
	});
	return isMounted;
};

```
