Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

277
Visualizações
How to print html text depending on condition using reactJs?

simple question here having this :

<Row>
   { "Client : " && elt.client?.libelle}
</Row>

I'd like that if elt.client is defined, displaying :

Client : client libelle

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Not sure exactly what you mean, but maybe this help?

<Row>
  {elt.client ? elt.client.libelle : elseStatement}
</Row>

Meaning: `if (elt.client) { return elt.client.libelle } else { return "whatever else you want" }

`

about 4 years ago · Juan Pablo Isaza Relatório

0

You can make use of ternary operator (? and : ). This operator is frequently used as an alternative to an if...else statement.

<Row>
 { elt?.client?.libelle ? ("Client : " + elt.client.libelle) : "" }
</Row>

It takes three operands: a condition followed by a question mark (?), then an expression to execute if the condition is truthy followed by a colon (:), and finally the expression to execute if the condition is falsy.

Also, you can utilise optional chaining (?.) operator of JavaScript which prevents an error if a reference is nullish (null or undefined).

In this case, if elt is undefined, it won't throw error. Hence, if all elt, elt.client and elt.client.libelle is defined and the value is no null, "Client : " + elt.client.libelle will display.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda