Skip to content

Commit 7c790d6

Browse files
useKeyboard hook fixed #17
1 parent 2580acc commit 7c790d6

File tree

3 files changed

+12
-26
lines changed

3 files changed

+12
-26
lines changed

README.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ yarn add react-native-hooks
2424
- [useCameraRoll](https://github.com/react-native-community/react-native-hooks#usecameraroll)
2525
- [useClipboard](https://github.com/react-native-community/react-native-hooks#useclipboard)
2626
- [useDimensions](https://github.com/react-native-community/react-native-hooks#usedimensions)
27-
- [useGeolocation](https://github.com/react-native-community/react-native-hooks#usegeolocation)
28-
- [useNetInfo](https://github.com/react-native-community/react-native-hooks#usenetinfo)
2927
- [useKeyboard](https://github.com/react-native-community/react-native-hooks#usekeyboard)
3028
- [useInteractionManager](https://github.com/react-native-community/react-native-hooks#useinteractionmanager)
3129
- [useDeviceOrientation](https://github.com/react-native-community/react-native-hooks#usedeviceorientation)
@@ -81,25 +79,15 @@ import { useDimensions } from 'react-native-hooks'
8179
const dimensions = useDimensions()
8280
```
8381

84-
### `useGeolocation`
85-
86-
```js
87-
import { useGeolocation } from 'react-native-hooks'
88-
89-
const [position, stopObserving, setRNConfiguration] = useGeolocation()
90-
91-
console.log('latitude: ', position.coords.latitude)
92-
```
93-
9482
### `useKeyboard`
9583

9684
```js
9785
import { useKeyboard } from 'react-native-hooks'
9886

9987
const keyboard = useKeyboard()
10088

101-
console.log('keyboard show: ', keyboard.show)
102-
console.log('keyboard height: ', keyboard.height)
89+
console.log('keyboard show: ', keyboard.isKeyboardShow)
90+
console.log('keyboard height: ', keyboard.keyboardHeight)
10391
```
10492

10593
### `useInteractionManager`

index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import useAppState from './lib/useAppState'
33
import useCameraRoll from './lib/useCameraRoll'
44
import useClipboard from './lib/useClipboard'
55
import useAccessibilityInfo from './lib/useAccessibilityInfo'
6-
import useGeolocation from './lib/useGeolocation'
76
import useKeyboard from './lib/useKeyboard'
87
import useInteractionManager from './lib/useInteractionManager'
98
import useDeviceOrientation from './lib/useDeviceOrientation'
@@ -14,7 +13,6 @@ export {
1413
useCameraRoll,
1514
useClipboard,
1615
useAccessibilityInfo,
17-
useGeolocation,
1816
useKeyboard,
1917
useInteractionManager,
2018
useDeviceOrientation,

lib/useKeyboard.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@ import { Keyboard } from 'react-native'
44
export default () => {
55
const [keyboard, setKeyboard] = useState({})
66

7-
keyboardWillShow = e => {
7+
function keyboardDidShow(e) {
88
setKeyboard({
99
isKeyboardShow: true,
1010
keyboardHeight: e.endCoordinates.height
1111
})
1212
}
1313

14-
keyboardWillHide = e => {
14+
function keyboardDidHide(e) {
1515
setKeyboard({
1616
isKeyboardShow: false,
1717
keyboardHeight: e.endCoordinates.height
1818
})
1919
}
2020

2121
useEffect(() => {
22-
this.keyboardWillShowListener = Keyboard.addListener(
23-
'keyboardWillShow',
24-
keyboardWillShow
22+
this.keyboardDidShowListener = Keyboard.addListener(
23+
'keyboardDidShow',
24+
keyboardDidShow
2525
)
26-
this.keyboardWillHideListener = Keyboard.addListener(
27-
'keyboardWillHide',
28-
keyboardWillHide
26+
this.keyboardDidHideListener = Keyboard.addListener(
27+
'keyboardDidHide',
28+
keyboardDidHide
2929
)
3030

3131
return () => {
32-
this.keyboardWillShowListener.remove()
33-
this.keyboardWillHideListener.remove()
32+
this.keyboardDidShowListener.remove()
33+
this.keyboardDidHideListener.remove()
3434
}
3535
}, [])
3636
return keyboard

0 commit comments

Comments
 (0)