How to change the textColor of TextInput in react native dynamically? -


hi guys want change textcolor of input dynamically. example in css placed color:'#fff',then want change text color whenever need '#ddd'.

you can use ternary operator check condition. has following format: (test conditon) ? true statement: false statement

based on that, can set <textinput> color this:

<textinput   style={[styles.input, (this.state.username ? styles.inputhighlight : null)]} //replace condition /> 

and add style stylesheet:

var styles = stylesheet.create({   input: {     //other styles     color:'#fff'   },   inputhighlight: {     color:'#ddd'   } });   

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -