Skip to content

Commit

Permalink
[fix][useKeyboard] Adapt unsubscription for new EventEmitter API
Browse files Browse the repository at this point in the history
  • Loading branch information
retyui committed Nov 12, 2021
1 parent c62cf6f commit 37566c5
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/useKeyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,7 @@ export function useKeyboard() {
]

return () => {
if (Keyboard.removeListener) {
// React Native < 0.65
Keyboard.removeListener('keyboardWillShow', handleKeyboardWillShow)
Keyboard.removeListener('keyboardDidShow', handleKeyboardDidShow)
Keyboard.removeListener('keyboardWillHide', handleKeyboardWillHide)
Keyboard.removeListener('keyboardDidHide', handleKeyboardDidHide)
} else {
// React Native >= 0.65
for (const subscription of subscriptions) {
subscription.remove()
}
}
subscriptions.forEach((subscription) => subscription.remove())
}
}, [])
return {
Expand Down

0 comments on commit 37566c5

Please sign in to comment.