Featured post
- Get link
- X
- Other Apps
How to hide keyboard in react native Keyboard.dismiss()
Hi friends,
Actually my requirement is to dismiss/hide the keyboard on completion of entering the text data in textInput.When i click outside the keyboard area,it should be dismissed.I tried many ways to implement the feature.Unfortunately i couldn't find any solution.
After more research,i found a better solution.So in this article,i will explain how we can dismiss/hide the keyboard by clicking outside area.
Step -1
Import TouchableWithoutFeedback and Keyboard from react native
Step -2
Wrap the View within the TouchableWithoutFeedback component
Step -3
Define onPress inside TouchableWithoutFeedback as shown below
<TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
<View style={{flex: 1}}>
----------------------
----------------------
</View>
</TouchableWithoutFeedback>
So by using TouchableWithoutFeedback and Keyboard components, we can easily hide or dismiss keyboard by clicking on the screen,outside area of keyboard,in react native way.This way of implementing reduces the number of code lines and provide better readability
I share my experience with you.It may help you
Thanks
Popular Posts
How to Check React Version Installed in Your System by Checking PACKAGE.JSON File and Executing Command from COMMAND PROMPT
- Get link
- X
- Other Apps
Execution failed for task ':react-native-reanimated:externalNativeBuildDebug' solved
- Get link
- X
- Other Apps
Error: Invalid `prisma.$executeRaw()` invocation: fixed using log: ["query"] option
- Get link
- X
- Other Apps
app keeps stopping error solved in android studio emulator using logcat in react native project
- Get link
- X
- Other Apps
ERROR Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined
- Get link
- X
- Other Apps