I\'m new to react native. I\'m trying to change the styling of the TextInput when there is an error.
How can I make my code not as ugly?
Update your code as following:
Then outside your class component, write:
getTextStyle(touched, invalid) {
if(touched && invalid) {
return {
height: 40, backgroundColor: 'white', borderRadius: 5, padding: 10, borderWidth: 2, borderColor: 'red'
}
} else {
return {
height: 40, backgroundColor: 'white', borderRadius: 5, padding: 10
}
}
}