Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On a press of the button : Hide keyboard in react-native

I have this simple screen

when I press in button the keyboard still apear How can I do this : " On a press of the button : Hide keyboard" ?

here is my code for button

        manage = () => {
           const { navigate } = this.props.navigation;
        if (this.state.text.length === 10) {

          navigate('service',{text: this.state.text});
        } else {
        Alert.alert('الرجاء ادخال الرقم  الوطني المكون من 10 أرقام')
        }
        }
        <Button   title='التالي'
           backgroundColor="#C1272D"
   onPress={this.manage}>
  </Button>
like image 725
Dina Avatar asked Dec 04 '22 19:12

Dina


1 Answers

Try this

import { Keyboard } from 'react-native'; 

Keyboard.dismiss()//Call where ever you needed

Docs here

like image 97
Aravind S Avatar answered Dec 06 '22 10:12

Aravind S