Daniel Logvin
Daniel Logvin

Reputation: 502

How can I apply a ternary operator in this code?

I'm trying to apply a ternary operator on this block of code and insert another if the condition is false. I find it a bit confusing because I've never used a ternary operator in this type of code blocks.

Thanks in advance!

Code:

{isNormalLoader && (
      <Dimmer active inverted>
        <Loader size="medium">{!textDisabled && loadingText}</Loader>
      </Dimmer>
)}

If the condition is false, display other component, but I don't have any clue on how to do it.

Upvotes: 0

Views: 46

Answers (1)

prasanth
prasanth

Reputation: 22510

You could do like this

{condition ? trueComponent : falseComponent}

For Your code:

{isNormalLoader ? <Dimmer active inverted><Loader size="medium">{!textDisabled && loadingText}</Loader></Dimmer> : <ForFalseComponent/>}

Upvotes: 3

Related Questions