react-native-autocomplete-dropdown
Version:
Dropdown Item picker with search and autocomplete (typeahead) functionality for react native
20 lines (16 loc) • 570 B
text/typescript
import { useEffect, useState } from 'react'
import { Keyboard } from 'react-native'
export function useKeyboardHeight() {
const [keyboardHeight, setKeyboardHeight] = useState(0)
useEffect(() => {
const showSubscription = Keyboard.addListener('keyboardDidShow', e =>
setKeyboardHeight(e.endCoordinates.height)
)
const hideSubscription = Keyboard.addListener('keyboardDidHide', () => setKeyboardHeight(0))
return () => {
showSubscription.remove()
hideSubscription.remove()
}
}, [setKeyboardHeight])
return keyboardHeight
}