keyboard event height react native
import { useEffect, useState } from 'react';
import { Keyboard, KeyboardEvent } from 'react-native';
export const useKeyboard = (): [number] => {
const [keyboardHeight, setKeyboardHeight] = useState(0);
function onKeyboardDidShow(e: KeyboardEvent): void {
setKeyboardHeight(e.endCoordinates.height);
}
function onKeyboardDidHide(): void {
setKeyboardHeight(0);
}
useEffect(() => {
Keyboard.addListener('keyboardDidShow', onKeyboardDidShow);
Keyboard.addListener('keyboardDidHide', onKeyboardDidHide);
return (): void => {
Keyboard.removeListener('keyboardDidShow', onKeyboardDidShow);
Keyboard.removeListener('keyboardDidHide', onKeyboardDidHide);
};
}, []);
return [keyboardHeight];
};
then in your component:
const [keyboardHeight] = useKeyboard();
console.log(keyboardHeight);
Also in JavaScript:
- initialize express app
- js indexof string
- javascript check if objects are equal
- js add data in object
- player.filter
- how to return character associated to character code javascript
- javascript add div to body with class
- is knex built into node js
- how to get data send from a form express
- jquery growl cdn
- how to get time and date from iso string javascript
- check browser locale javascript
- compare string length javascript
- show hide more text jquery
- javascript best way to loop through array
- javascript string interpolation
- circle collision javascript
- You are running Node 8.10.0. Create React App requires Node 10 or higher. Please update your version of Node.
- Exception in thread "main" org.openqa.selenium.JavascriptException: cannot read getPlayerState
- javascript months array
- await async sleep
- javascript how to trigger and event
- can i use redux connect without react
- babylon js camera position