react-native 关闭软键盘需要点击两次才能触发事件解决方法

软键盘消失,焦点依然还在textInput中导致需要点击两次按钮,监听软键盘的消失方法,然后在消失方法里面,再一次调用软键盘消失方法

const dismissKeyboard = require('dismissKeyboard'); //引入

componentWillMount () {
   this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', this._keyboardDidShow);
   this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', this._keyboardDidHide);
}

componentWillUnmount() {
   this.keyboardDidShowListener.remove();
   this.keyboardDidHideListener.remove();
}

 _keyboardDidShow () {

}
_keyboardDidHide () {
   dismissKeyboard();
}

你可能感兴趣的:(react-native 关闭软键盘需要点击两次才能触发事件解决方法)