Reputation: 43
When I change the input to '' and submit it (in the TextInput) I have the following error: "Failed prop type: Invalid prop 'value' of type 'object' supplied to 'TextInput'"
<TextInput
style={styles.input}
autoCapitalize='none'
onChange={email => this.setState({email})}
value={this.state.email}
>
Upvotes: 0
Views: 633
Reputation: 9779
if you have defined your state like this
state={email:''} // or
this.state={email:''}
changed code
<TextInput
style={styles.input}
autoCapitalize='none'
onChange={e=> this.setState({email:e.target.value})}
value={this.state.email}
>
Upvotes: 0
Reputation: 5700
Your onChange()
method should be as follow:
<TextInput
style={styles.input}
autoCapitalize='none'
onChange={(e) => {
this.setState({
email: e.nativeEvent.text
})
}}
value={this.state.email}
>
Or you can just use onChangeText()
to assing entered text into your state as below :
<TextInput
style={styles.input}
autoCapitalize='none'
onChangeText={(email) => this.setState({ email })}
value={this.state.email}
>
More doc here.
Upvotes: 1