Skip to content

Commit e9b35d9

Browse files
authored
Added keyboardHeight property to useKeyboard
The keyboardHeight property was documented in the [README](https://github.com/react-native-community/react-native-hooks/blob/master/README.md#usekeyboard) however was missing in the actual useKeyboard hook
1 parent 9dbb827 commit e9b35d9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/useKeyboard.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,23 @@ export default function useKeyboard() {
1010
start: { screenX: 0, screenY: 0, width: 0, height: 0 },
1111
end: { screenX: 0, screenY: 0, width: 0, height: 0 },
1212
})
13+
const [keyboardHeight, setKeyboardHeight] = useState<number>(0)
1314

1415
const handleKeyboardWillShow: KeyboardEventListener = (e) => {
1516
setCoordinates({ start: e.startCoordinates, end: e.endCoordinates })
1617
}
1718
const handleKeyboardDidShow: KeyboardEventListener = (e) => {
1819
setShown(true)
1920
setCoordinates({ start: e.startCoordinates, end: e.endCoordinates })
21+
setKeyboardHeight(e.endCoordinates.height)
2022
}
2123
const handleKeyboardWillHide: KeyboardEventListener = (e) => {
2224
setCoordinates({ start: e.startCoordinates, end: e.endCoordinates })
2325
}
2426
const handleKeyboardDidHide: KeyboardEventListener = (e) => {
2527
setShown(false)
2628
setCoordinates({ start: e.startCoordinates, end: e.endCoordinates })
29+
setKeyboardHeight(0)
2730
}
2831

2932
useEffect(() => {
@@ -55,5 +58,6 @@ export default function useKeyboard() {
5558
return {
5659
keyboardShown: shown,
5760
coordinates,
61+
keyboardHeight
5862
}
5963
}

0 commit comments

Comments
 (0)