lundi 22 février 2021

Is there a way to do "if/else if/else" statements ( aka check multiple conditions ) inline in React JSX?

So I know that if I only have one condition to check I can put { condition ? results : elseresults } in JSX instead of the

if (condition) {
  results
} else {
  elseresults
}

in normal Javascript. But is there a way to check multiple conditions, where I would do

if (condition) {
} else if (condition 2) {
} else {
}

in normal JavaScript?

Aucun commentaire:

Enregistrer un commentaire