Closed mindplay-dk closed 3 years ago
Ah! thanks for catching @mindplay-dk! Right now there are two ways to do conditions, ternaries are coming up on my todo list
In the meantime, you can use the facade <Show />
component, like
import { Show } from '@builder.io/mitosis'
<Show when={showName}><input ... /></Show>
<Show when={!showName}>Name editor disabled</Show>
or &&
boolean operator
import { Show } from '@builder.io/mitosis'
{showName && <input ... />}
{!showName && <>Name editor disabled</>}
Def agree that ternary needs support, will keep this open until added shortly
Implemented locally, will be merged soon
Beta support added, if you hit any issues lmk and happy to look into
Any plans to support conditional expressions with JSX?
This is fairly idiomatic - not just to React, but to JSX with most frameworks and libraries.
It looks like you do support loops so I was a bit surprised you don't see to support conditionals - it seems like loops would be more difficult to implement, so maybe this is just a bug?
Either way, loops and conditionals are both pretty essential to building any UI, I think. 🙂