When i press an input in react-native , the keyboard pops an opens. I would like to close the keyboard (ONLY) when pressing some button. How can i do this?
asked Jun 27, 2016 at 14:19
Vandervidi
6902 gold badges15 silver badges35 bronze badges
1 Answer 1
You can dismiss the keyboard by using Keyboard.dismiss.
import { Keyboard } from 'react-native';
<Touchable onPress={Keyboard.dismiss}>...</Touchable>
If you're using a ScrollView you'll need to set keyboardShouldPersistTaps prop to true.
Sign up to request clarification or add additional context in comments.
3 Comments
Vandervidi
Working perfectly!
panurg
@oblador did you mean this one: react-native-dismiss-keyboard when you wrote from 'dismissKeyboard'?
Aldor
What if we are using a FlatList inside ?