ml-in-barcelona / jsoo-react

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

external%component props from optional arguments are wrapped in option #125

Closed glennsl closed 2 years ago

glennsl commented 2 years ago

There seems to be no special handling of optional arguments for external%component, which means that optional arguments are passed in as option values.

Given

external%component my_component ?num_leprechauns:int -> React.element = "..."

my_component () will cause 0 to be passed as num_leprechauns.

my_component ~num_leprechauns:42 () will cause [0, 42] to be passed as num_leprechauns.

It might be sufficient to convert the option value to a Js.optdef value, but I think the proper solution is to omit it from the props object if the argument is not passed. I'll try doing the simpler thing for now though.