diff --git a/README.md b/README.md index a26fa34bce..f361275c9b 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ - [`useEffectOnce`](./docs/useEffectOnce.md) — a modified [`useEffect`](https://reactjs.org/docs/hooks-reference.html#useeffect) hook that only runs once. - [`useEvent`](./docs/useEvent.md) — subscribe to events. - [`useLifecycles`](./docs/useLifecycles.md) — calls `mount` and `unmount` callbacks. - - [`useMountedState`](./docs/useMountedState.md) ~~and [`useRefMounted`](./docs/useRefMounted.md)~~ — track if component is mounted. + - [`useMountedState`](./docs/useMountedState.md) — track if component is mounted. - [`usePromise`](./docs/usePromise.md) — resolves promise only while component is mounted. - [`useLogger`](./docs/useLogger.md) — logs in console as component goes through life-cycles. - [`useMount`](./docs/useMount.md) — calls `mount` callbacks. diff --git a/docs/useRefMounted.md b/docs/useRefMounted.md deleted file mode 100644 index 0e7d708eb5..0000000000 --- a/docs/useRefMounted.md +++ /dev/null @@ -1,28 +0,0 @@ -# `useRefMounted` - ->**DEPRECATED** ->This method is obsolete, use `useMountedState` instead. - -Lifecycle hook that tracks if component is mounted. Returns a ref, which has a -boolean `.current` property. - - -## Usage - -```jsx -import {useRefMounted} from 'react-use'; - -const Demo = () => { - const refMounted = useRefMounted(); - - useEffect(() => { - setTimeout(() => { - if (refMounted.current) { - // ... - } else { - // ... - } - }, 1000); - }); -}; -``` diff --git a/src/__stories__/useRefMounted.story.tsx b/src/__stories__/useRefMounted.story.tsx deleted file mode 100644 index 5a8c22b6a9..0000000000 --- a/src/__stories__/useRefMounted.story.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { storiesOf } from '@storybook/react'; -import * as React from 'react'; -import { useRaf, useRefMounted } from '..'; -import ShowDocs from './util/ShowDocs'; - -const Demo = () => { - const refMounted = useRefMounted(); - - useRaf(); - return ( -
-

**DEPRECATED**

-

This method is obsolete, use `useMountedState` instead.

- is mounted: {refMounted.current ? '👍' : '👎'} -
- ); -}; - -storiesOf('Lifecycle|useRefMounted', module) - .add('Docs', () => ) - .add('Demo', () => ); diff --git a/src/index.ts b/src/index.ts index 83761805e3..4ff7384e92 100644 --- a/src/index.ts +++ b/src/index.ts @@ -64,10 +64,6 @@ export { default as usePromise } from './usePromise'; export { default as useRaf } from './useRaf'; export { default as useRafLoop } from './useRafLoop'; export { default as useRafState } from './useRafState'; -/** - * @deprecated This hook is obsolete and Will be removed soon, use `useMountedState` instead - */ -export { default as useRefMounted } from './useRefMounted'; export { default as useSearchParam } from './useSearchParam'; export { default as useScroll } from './useScroll'; export { default as useScrolling } from './useScrolling'; diff --git a/src/useRefMounted.ts b/src/useRefMounted.ts deleted file mode 100644 index 5d285db014..0000000000 --- a/src/useRefMounted.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { RefObject, useEffect, useRef } from 'react'; - -/** - * @deprecated This hook is obsolete, use `useMountedState` instead - */ -const useRefMounted = (): RefObject => { - const refMounted = useRef(false); - - useEffect(() => { - refMounted.current = true; - - return () => { - refMounted.current = false; - }; - }, []); - - return refMounted; -}; - -/** - * @deprecated This hook is obsolete, use `useMountedState` instead - */ -export default useRefMounted;