reactjs – React native textDecoration properties not working on Android-ThrowExceptions

Exception or error:

I am using on

<Text style={styles.sampleStyle}> Something </Text>

the following styles:

sampleStyle: {
    textDecorationLine: "underline",
    textDecorationStyle: "solid",
    textDecorationColor: "#000",
}

However, they don’t seem to be working. What am I doing wrong?

How to solve:

You didn’t specify the style you want for your Text component. Try with :

<Text style={styles.sampleStyle} >Something </Text>

var styles = StyleSheet.create({
  sampleStyle: {
    textDecorationLine: "underline",
    textDecorationStyle: "solid",
    textDecorationColor: "#000"
  }
});

###

<Text style={styles.sampleStyle}>Something</Text>

var styles = StyleSheet.create({
sampleStyle: {
color: "#000"
}
});

An old question, but here’s a quick answer for those still searching in 2020+

For Android it seems that simply using color: is what is needed. If you take a look at the docs, textDecorationColor is labeled for ios use.
https://reactnative.dev/docs/text-style-props

Leave a Reply

Your email address will not be published. Required fields are marked *