top | item 37133449 (no title) jpochtar | 2 years ago Yeah you have to do <If cond={...} then={() => ... } els={() => ... } /> so the `then` and `els` branches only get evaluated if needed discuss order hn newest SkyPuncher|2 years ago We use ternary extensively with in JSX. Keeps the logic in vanilla JS{ some_condition ? ( <H2>It was true</H2> ) : ( <H2>It was false</H2> ) mbork_pl|2 years ago Even though I'm a JS programmer myself and I do use similar constructs once in a while, I have to admit that this gets dangerously close to the Greenspun's tenth rule... In times like this I miss proper Lisp macros. gdprrrr|2 years ago Which has ugly untax IMO
SkyPuncher|2 years ago We use ternary extensively with in JSX. Keeps the logic in vanilla JS{ some_condition ? ( <H2>It was true</H2> ) : ( <H2>It was false</H2> )
mbork_pl|2 years ago Even though I'm a JS programmer myself and I do use similar constructs once in a while, I have to admit that this gets dangerously close to the Greenspun's tenth rule... In times like this I miss proper Lisp macros.
SkyPuncher|2 years ago
{ some_condition ? (
) : (mbork_pl|2 years ago
gdprrrr|2 years ago