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,279
  • 15
  • 74
  • 148

1 Answers1

4

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,667
  • 2
  • 19
  • 32