ml-in-barcelona / jsoo-react

js_of_ocaml bindings for ReactJS. Based on ReasonReact.
https://ml-in-barcelona.github.io/jsoo-react
MIT License
137 stars 19 forks source link

A few ergonomic additions for dealing with conditional rendering #165

Closed glennsl closed 2 years ago

glennsl commented 2 years ago

The addition of maybe for elements is a slightly breaking change, as it shadows maybe for Prop. It's a very low effort fix though.

Another ergonomic addition I've considered is making the attributes optional with an ~a labeled argument, as in tyxml, and the addition of short-hand labeled arguments for id and className attributes, as I've noticed that I very rarely use any attributes other than className, which is used quite often. But I'm thinking it might be better to keep the DSL simple and add a ppx layer for even better ergonomics instead without any runtime cost.

glennsl commented 2 years ago

I just realized that React.null exists, and should probably be copied to the DSL. null seems like a pretty bad name though, unless you want to optimize for familiarity with JavaScript's null. So not sure if it should be 'none' or 'null' in the DSL.