Hacker News new | ask | show | jobs
by yodon 2546 days ago
Ok, I should probably edit my comment to "JSX/TSX feels so incredibly natural except for needing to use JS ternaries for conditional rendering" because seriously what were they thinking there?
2 comments

This is more of an issue with JS than React. ReasonML also has JSX support and since `if` is an expression rather than a statement you can do this:

    <div>
      {if (cond) {
        <Comp1 />
      } else {
        <Comp2 />
      }}
    </div>
Or even:

    <div>
      {switch (expr) {
      | A => <CompA />
      | B => <CompB />
      | _ => <CompC />
      }}
    </div>
maybe do-expression proposal could help https://github.com/tc39/proposal-do-expressions