React Native Hook for Keyboard
npm install @rnhooks/keyboard> React Native hook for keyboard
``bash`
yarn add @rnhooks/keyboard
> Note
>
> v1.0.0 and above is only supported on react-native >= 0.65, for older react-native use the older release.
`js
import useKeyboard from '@rnhooks/keyboard';
function App() {
const [visible, dismiss] = useKeyboard();
return (
);
}
`
If you like, you can configure the hook to use the will events instead of thedid events (by default, it uses the did events). This is useful in cases
where you want to trigger an animation before the keyboard begins dismissing:
`js`
useKeyboard({
useWillShow: true,
useWillHide: true,
})
| Name | Default | Type | Description |
| ----------- | ------- | -------:| ----------------------------------------- |
| useWillShow | false | boolean | Use the keyboardWillShow event instead. |false
| useWillHide | | boolean | Use the keyboardWillHide event instead. |
| Name | Default | Type | Description |
| ------- | ------------------- | --------:| ------------------- |
| visible | false | boolean | Keyboard Visibility |Keyboard.dismiss` | function | Dismiss Keyboard |
| dismiss |