homerboy homerboy - 7 months ago 74
CoffeeScript Question

If...then in JSX for Javascript

I've been writing Coffeescript/JSX and this is valid syntax:

<input type={if @state.name == "Test" then "checkbox"}/>

How do I do the same for plain Javascript? There is no
clause and I don't think I can do inline
checks like I can in Coffee?


Taking the answer from How to write an inline IF statement in JavaScript?

You can use the syntax 10 < 11 ? do this : do that where the ? is the then and the : is the else.