单击搜索按钮后,我执行此功能。所以在手机视图中,在搜索栏中键入后,当我点击手机中的搜索按钮时,键盘会一直打开。如何在执行搜索后隐藏。
const onSearch = async (e) => {
if(e.which === 13 && searchKeyword !== null || e.type === 'click' && searchKeyword !== null){
dispatch(searchProduct(searchKeyword))
setTimeout(() => {
props.history.push({
pathname: '/searchresults',
state: {from: searchKeyword}
})
}, 500)
}
}
您可以使用Keyboard.dismiss函数!
import {Keyboard} from 'react-native'
const onSearch = async (e) => {
/* Function logic */
Keyboard.dismiss()
}