好吧,这是一个令人尴尬的问题,但我无法让这个 TextInput 接受我输入的值。
它只是在我键入它时尽可能快地删除它 - 我很确定记录 this.state.code 会显示一个空变量。
是不是我的键盘类型有问题?我需要执行 .toString()
吗?
constructor() {
super()
this.state = {
code: '12'
}
}
<TextInput
onChangedText={(text) => this.setState({code: text})}
value={this.state.code}
keyboardType='numeric'
style={styles.input}
placeholder='Code'
maxLength={4}
/>
最佳答案
正确的属性是onChangeText
。不是 onChangedText
关于react-native - React Native TextInput 不更新状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43131236/