Skip to content

Instantly share code, notes, and snippets.

@marcovincit
Created July 23, 2020 01:13
Show Gist options
  • Save marcovincit/dae93f4c18727a589fc60cc9cb988e4c to your computer and use it in GitHub Desktop.
Save marcovincit/dae93f4c18727a589fc60cc9cb988e4c to your computer and use it in GitHub Desktop.
Vew height without keyboard react native
import React, { useEffect, useState } from "react";
import { Keyboard, TextInput, Dimensions } from "react-native";
const Example = () => {
const [heightDefined, setHeightDefined] = useState(100);
useEffect(() => {
Keyboard.addListener("keyboardDidShow", (e) => {
setHeightDefined(
Dimensions.get("window").height - e.endCoordinates.height
);
});
Keyboard.addListener("keyboardDidHide", (e) => {
setHeightDefined(100);
});
}, []);
return (
<TextInput
style={{
borderWidth: 1,
backgroundColor: "pink",
height: heightDefined,
}}
placeholder="Click here ..."
onSubmitEditing={Keyboard.dismiss}
/>
);
};
export default Example;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment