I have some code that is meant to eliminate placeholders onFocus and return them onBlur, it seems to work properly for the login text input, but not for the password one. Do you mind having a look at the code?
This is the method in question:
togglePlaceholder = (nodeType:string,localStateValue:string) => {
switch (eval(`this.state.${localStateValue}`)) {
case nodeType:
return this.setState({[localStateValue]:null});
case null:
return this.setState({[localStateValue]:nodeType});
}
}
I'm using eval here because I'm planning to reuse this function across multiple components to toggle their local state.
These are the components:
<TextInput style={styles.logInFormInput}
placeholder={this.state.logInPlaceholder}
onFocus={()=>this.togglePlaceholder('login','logInPlaceholder')}
onBlur={()=>this.togglePlaceholder('login','logInPlaceholder')}
></TextInput>
<TextInput style={styles.logInFormInput}
secureTextEntry={true}
placeholder={this.state.passwordPlaceholder}
onFocus={()=>this.togglePlaceholder('password','passwordPlaceholder')}
onBlur={()=>this.togglePlaceholder('password','passwordPlaceholder')}
></TextInput>
Seems to be working properly for login, but not password.