Reputation:
I cannot update the existing value in text input.
<TextField
label='Email Id'
//placeholder={value_email}
onChangeText={(email) => this.setState({ email })}
value={value_email}
/>
here value_email is
const value_email = this.state.userInfo.email;
Thanks.
Upvotes: 0
Views: 164
Reputation: 12210
You are setting the state wrog , if you want to store inside an object userInfo state , try this :
<TextInput
label='Email Id'
style={{ height: 40, borderColor: 'gray', borderWidth: 1 }}
//placeholder={value_email}
onChangeText = {(email) =>this.setState(prevState => { let userInfo = Object.assign({}, prevState.userInfo); userInfo.email = email
return { userInfo }; }) }
value={this.state.userInfo.email}
/>
Now you can get the value as const value_email = this.state.userInfo.email;
Upvotes: 0
Reputation: 11297
this.setState({ email }
Sets the email to state object (this.state.email) but you are reading it from state.userInfo
.
If you are setting it to state variable you need to change to
const value_email = this.state.email;
Upvotes: 1