1

Is this sort of thing possible?

<Text style={{ opacity: ${ "blue" == "blue" ? 1 : 0 }, textAlign:"right" }}>Retry</Text>

I know this isn't HOW you do it because it isn't working. But was wondering if there was a way to conditionally create styling without creating an object.

bryan
  • 8,879
  • 18
  • 83
  • 166

1 Answers1

7

You don't need ${ }, i.e.:

<Text style={{ opacity: "blue" == "blue" ? 1 : 0, textAlign:"right" }}>Retry</Text>

Or to make opacity completely optional you could do something like this:

<Text style={{ opacity: "blue" == "blue" ? 1 : null, textAlign:"right" }}>Retry</Text>
linasmnew
  • 3,907
  • 2
  • 20
  • 33