从状态设置为textinput的值,并更新onChangeText状态。仍然textInput中的值没有改变。在模拟器中运行它没有问题。它仅在设备中运行时发生。相同的代码在android设备和模拟器上没有问题。
class CompanyDetailsInput extends Component {
constructor(props) {
super(props)
this.state = {
email: props.profile.Email,
}
render() {
return (
<TextInput
value={this.state.email}
editable={this.props.editable}
onChangeText={(email) => {
this.email(email)
}}
autoCorrect={false}
blurOnSubmit={false}
returnKeyType={"next"}
keyboardType={"default"}
</TextInput>
)}
}
答案 0 :(得分:0)
您需要setState
onChangeText
,所以
class CompanyDetailsInput extends Component {
constructor(props) {
super(props)
this.state = {
email: props.profile.Email,
}
render() {
return (
<TextInput
value={this.state.email}
editable={this.props.editable}
onChangeText={(x)=> this.setState({ email: x })}
autoCorrect={false}
blurOnSubmit={false}
returnKeyType="next"
keyboardType="default"
/>
)
}
}