diff --git a/src/hooks/useKeyboard.ts b/src/hooks/useKeyboard.ts index 67e3a31e1..18293801b 100644 --- a/src/hooks/useKeyboard.ts +++ b/src/hooks/useKeyboard.ts @@ -86,26 +86,19 @@ export const useKeyboard = () => { ); }; - Keyboard.addListener( + const showSubscription = Keyboard.addListener( KEYBOARD_EVENT_MAPPER.KEYBOARD_SHOW, handleOnKeyboardShow ); - Keyboard.addListener( + const hideSubscription = Keyboard.addListener( KEYBOARD_EVENT_MAPPER.KEYBOARD_HIDE, handleOnKeyboardHide ); return () => { - Keyboard.removeListener( - KEYBOARD_EVENT_MAPPER.KEYBOARD_SHOW, - handleOnKeyboardShow - ); - - Keyboard.removeListener( - KEYBOARD_EVENT_MAPPER.KEYBOARD_HIDE, - handleOnKeyboardHide - ); + showSubscription.remove(); + hideSubscription.remove(); }; }, [handleKeyboardEvent]);