reactjs - ListView 中的 TouchableOpacity 需要点击 2 次才能实现 onPress
问题描述
我有一个 TextInput,它将呈现一个 ListView 提示文本到 AutoComplete 但是 TouchableOpacity 需要 2 次点击才能触发(首先关闭键盘)
添加keyboardShouldPersistTaps="always"
到ListView
并不能解决问题。
代码:
render() {
const { selected, searched } = this.state;
return (
<View>
<TextInput
onChangeText={this.searchedText}
underlineColorAndroid="transparent"
onBlur={this.blurInput}
/>
<ListView
keyboardShouldPersistTaps="handled"
style={styles.autoCompleteListView}
dataSource={ds.cloneWithRows(searched)}
renderRow={this.renderRow.bind(this)}
/>
</View>
);
}
...
renderRow = (rowData) => (
<TouchableOpacity
onPress={this._onPressRow.bind(this, rowData)}
>
<Text>{ rowData }</Text>
</TouchableOpacity>
);
解决方案
https://github.com/facebook/react-native/issues/10138#issuecomment-304344283
所有嵌套组件都需要该keyboardShouldPersistTaps
属性
推荐阅读
- python - 以概率启动 cronjob
- javascript - 如何在其类索引中获取输入的值并将其分配给在其自己的集合中具有相同索引的另一个输入?
- image - 在 README.md 中插入内联图像
- php - Steam AUTH 对重定向变量感到好奇
- php - 防止 DOMDocument 转义 html
- python - Mongodb DeprecationWarning:不推荐使用计数。请改用 Collection.count_documents
- node.js - Socket.io:无法读取未定义的属性“发射”
- azerothcore - 尝试为 azerothcore 安装 soloLFG 模块时出错
- laravel - 如何在 laravel 中仅获取名称值请建议
- python - Pandas 按重复日期分组