Could if/else and for/in statements be added to JSX? #2432
willfaught
started this conversation in
General
Replies: 1 comment
-
You can already use ternary statements in JSX blocks: // Instead of
{if condition1}
<p>Outcome 1</p>
{else if condition2}
<p>Outcome 2</p>
{end}
// You can already use
{condition1
? <p>Outcome 1</p>
: condition2
? <p>Outcome 2</p>
: <></>} Loops are a bit more difficult, since to make them reactive, you'll need mapArray. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Show, Switch, and For seem like workarounds or shims rather than ideal solutions:
Plus you have to import them:
It seems like it would be better to have some limited templating features:
These could be transformed into inline functions that are immediately invoked:
Maybe that's way out of scope for this project, I dunno.
This seems like an obvious direction to take, so I'm guessing there's a reason why this hasn't been pursued in the past by this or other projects? Maybe it wouldn't work for some reason? Just curious.
Beta Was this translation helpful? Give feedback.
All reactions