Thanks to @alexfedoseev in the ReasonML Discord channel:
In JS, click / blur / focus are methods on DOM element object. In Reason, one must use the appropriate functions to call these methods.
There exist 2 ways to achieve it:
- Less type-safe, provided by ReasonReact:
domRef
->React.Ref.current
->Js.Nullable.toOption
->Option.map(el => el->ReactDOMRe.domElementToObj##click())
->ignore;
- Type-safe, but requires Webapi package:
Webapi.Dom.(
domRef
->React.Ref.current
->Js.Nullable.toOption
->Option.flatMap(Element.asHtmlElement)
->Option.map(HtmlElement.click)
);
PSA: If you frequent the ReasonML Discord channel and found this helpful, please consider adding answers received via chat (especially those likely to get asked frequently) to the ReasonML.chat forum. Hopefully this will reduce the load on those providing help in the Discord channel, and make the learning curve a bit shallower for those Googling for help.