4 ms·
Personally I prefer the ternary operator in those cases, however I think do expressions will fix most of the if/else awkward stuff: https://babeljs.io/docs/plug
by spion 9y ago
Personally I prefer the ternary operator in those cases, however I think do expressions will fix most of the if/else awkward stuff: https://babeljs.io/docs/plugins/transform-do-expressions/ https://babeljs.io/docs/plugins/transform-do-expressions/
- gunn 9y agoCan that actually help react look better here? I'm currently imagining: { do { if (condition_expression) { template_evaluation } }}
- spion 9y agoFor a single expression some of it can be omitted: { do { if (condition_expression) template_evaluation }} But I gues thats not really better. I'm hoping jsx will eventually default to `do` expressions though, and then it becomes { if (conditional_expression) template_evaluation }
- elyobo 9y agoI'll use a ternary if I want something in the "else" case, but otherwise the `&&` / `||` approach is more readable to me (there's more to read in a ternary to figure out that there's nothing happening in the else case, whereas it's obvious with the boolean approach without reading further).