6 ms·
I mean, yeah, the ternary operator is part of JS syntax. But it WAS React’s choice to not include any alternative way to if/else add an element (there is an if/
by farazzz 3y ago
I mean, yeah, the ternary operator is part of JS syntax. But it WAS React’s choice to not include any alternative way to if/else add an element (there is an if/else but only for the entire component, not just for conditionally adding one element within a component). So indirectly this is React’s syntax decision.
- Capricorn2481 3y agoBecause React is JS and Svelte isn't
- farazzz 3y agoReact is JSX* Nothing preventing them from making an <If condition={…}>…<Else>… component
- MrJohz 3y agoAnd this is typically how conditionals work in SolidJS, which also uses JSX but adds extra core components to handle conditionals and iteration. In fairness, this is largely because they can better support the reactivity model that SolidJS uses, but it's a convenient side effect.