diff --git a/package.json b/package.json index 3309e72..1f06855 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-hook-notification", - "version": "2.2.5", + "version": "2.2.6", "license": "MIT", "main": "dist/main/index.js", "typings": "dist/main/index.d.ts", diff --git a/src/presentation/components/Notification/useController.ts b/src/presentation/components/Notification/useController.ts index c055f2a..50a6440 100644 --- a/src/presentation/components/Notification/useController.ts +++ b/src/presentation/components/Notification/useController.ts @@ -25,7 +25,6 @@ import { import { getAnimation } from '../../utils/getAnimation'; import { useNotificationWidth } from '../../hooks/useNotificationWidth'; import { useLimitToRemove } from '../../hooks/useLimitToRemove'; -import { useIsMounted } from '../../hooks/useIsMounted'; type UseControllerHookProps = { dragDirection: NotificationDragDirection; @@ -222,16 +221,14 @@ export const useController: UseControllerHook = ({ const delayDecrement = useRef(delay / DELAY); const timerRef = useRef(); - const isMounted = useIsMounted(); const onExecuteTimer = useCallback((): void => { timerRef.current = setInterval(() => { delayDecrement.current -= 1; - const canExecute = isMounted() && delayDecrement.current === 0; - if (canExecute) { + if (delayDecrement.current === 0) { onRemove(); } }, DELAY); - }, [onRemove, isMounted]); + }, [onRemove]); useEffect(() => { const canExecute = autoClose && !isPaused; diff --git a/src/presentation/hooks/__tests__/useIsMounted.spec.ts b/src/presentation/hooks/__tests__/useIsMounted.spec.ts deleted file mode 100644 index 50d3eb3..0000000 --- a/src/presentation/hooks/__tests__/useIsMounted.spec.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { renderHook } from '@testing-library/react-hooks'; - -import { useIsMounted } from '../useIsMounted'; - -describe('useIsMounted hook', () => { - it('should be able to return mounted value', async () => { - const { result, rerender } = renderHook(useIsMounted); - rerender(); - - expect(result.current()).toBeTruthy(); - }); - - it('should be able to return unmounted value', async () => { - const { result, unmount } = renderHook(useIsMounted); - unmount(); - - expect(result.current()).toBeFalsy(); - }); -}); diff --git a/src/presentation/hooks/useIsMounted.ts b/src/presentation/hooks/useIsMounted.ts deleted file mode 100644 index 0694cf6..0000000 --- a/src/presentation/hooks/useIsMounted.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { useCallback, useEffect, useRef } from 'react'; - -type Return = () => boolean; - -export const useIsMounted = (): Return => { - const isMount = useRef(false); - - useEffect(() => { - isMount.current = true; - - return () => { - isMount.current = false; - }; - }); - - return useCallback((): boolean => isMount.current, []); -};