We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c62cf6f commit 13355e0Copy full SHA for 13355e0
src/useKeyboard.ts
@@ -50,17 +50,17 @@ export function useKeyboard() {
50
]
51
52
return () => {
53
- if (Keyboard.removeListener) {
+ if (typeof subscriptions?.[0]?.remove === 'function') {
54
+ // React Native >= 0.65
55
+ for (const subscription of subscriptions) {
56
+ subscription.remove()
57
+ }
58
+ } else {
59
// React Native < 0.65
60
Keyboard.removeListener('keyboardWillShow', handleKeyboardWillShow)
61
Keyboard.removeListener('keyboardDidShow', handleKeyboardDidShow)
62
Keyboard.removeListener('keyboardWillHide', handleKeyboardWillHide)
63
Keyboard.removeListener('keyboardDidHide', handleKeyboardDidHide)
- } else {
- // React Native >= 0.65
- for (const subscription of subscriptions) {
- subscription.remove()
- }
64
}
65
66
}, [])
0 commit comments