5 ms·
Yeah you have to do <If cond={...} then={() => ... } els={() => ... } /> so the `then` and `els` branches only get evaluated if needed
by jpochtar 3y ago
Yeah you have to do
<If cond={...} then={() =>
...
} els={() =>
...
} />
so the `then` and `els` branches only get evaluated if needed
- gdprrrr 3y agoWhich has ugly untax IMO
- SkyPuncher 3y agoWe 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 3y agoEven 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.