user7910922
user7910922

Reputation:

Trying to clear input placeholder on focus/touch

This is my code:

<TextInput value={this.state.task} underlineColorAndroid={'transparent'} placeholder = {'+ הוסף משימה חדשה'}
            style={styles.input}
            onChangeText={(text) => {
              this.setState({task: text});
            } }
            onEndEditing={()=> this.addTask()}
            />

Not sure how I can do this. Hope someone can help. Thanks!

Upvotes: 3

Views: 3061

Answers (1)

Dhiraj
Dhiraj

Reputation: 33618

You can use the onFocus method like this

<TextInput
  value={this.state.task}
  onFocus={() => this.onFocus()}
/>

onFocus() {
  this.setState({
    task: ''
  });
}

Upvotes: 1

Related Questions