react-native - 在 TextInput 中粘贴值期间未触发 onChangeText
问题描述
onChangeText
在 IOS 的 TextInput 中粘贴值期间不会触发。怎么可能修复它?这是我的TextInput
:
<TextInput
value={this.state.username}
style={styles.input}
placeholder='Email'
placeholderTextColor='#9D9D9D'
returnKeyType='next'
selectTextOnFocus={true}
onSubmitEditing={() => this.passwordRef.focus()}
autoCapitalize='none'
autoCorrect={false}
autoComplete='email'
keyboardType='email-address'
onChangeText={ text => this.onChangeEmail('username', text) }
/>
onChangeEmail = async (key, value) => {
await this.setState({ [key]: value })
const { username } = this.state
if (username.trim() === "") {
this.setState(() => ({ emailError: "Required"}));
return
}
else if (!username.match(/.+@.+/) ){
this.setState(() => ({ emailError: "Not an email address"}));
return
}
else {
this.setState(() => ({ emailError: null}));
}
}
解决方案
我找到了这个问题的解决方案,而不是onChangeText
, 我使用onChange
, 之后TextInput
按预期开始工作。
推荐阅读
- wpf - WPF 等效于 jQuery 的类选择器
- django - 依赖登录的Django缓存和页面部分
- laravel - 未找到 Laravel 类 'Illuminate\Support\Facades\Http'
- python - 删除python中的重复记录
- java - 使用 jFreeChart StandardXYItemRenderer 如何设置线条和/或形状可见性
- javascript - 如何允许用户在电子中选择目录?
- flutter - 如何在共享首选项中保存 Firestore 数据,未为“DocumentSnapshot”类型定义运算符“[]”
- python - 如何在 p.terminate() 之后立即获得 p.exitcode=None?
- oracle - 连接到 Oracle XE Docker 容器
- python - 如何使用 Python 创建 Windows 服务