On a higher level: nothing. Because there’s no such thing as curried call in JS. The fact that externals compile to clean uncurried code is a special case actually.
Edit: believer beat me to it. But yes, if you want to also bind to Toaster as a default export, then add that too. Basically, use @send.
A follow up question. Now I’m trying to bind to the headlessui package from TailwindLabs.
I’m trying to use a named export from their package called Transition.
Normally I would import it like this: import { Transition } from '@headlessui/react' and then just use the Transition component in my markup.
This got me a long way. Thank you very much!
The next blocker I’m facing is how to map the Transition.Child from the package.
I can see that you don’t use it yet, so there’s not a solution I can steal
The TransitionChild is not exported so again I’m unsure how to go about this.
But I get the error Attempted import error: 'Child' is not exported from '@headlessui/react' (imported as 'React$1').
I’m guessing I need to change the type returned from Transition element. But how do I create a type that will allow Transition itself to be a React.element and also have a Child which is a React.element?
In case you don’t know: You can find all our interop decorators (+ examples) in our syntax discovery widget (feel free to open an issue on the docs issue tracker in case anything you find there is unclear)
We appreciate the questions / threads! Keep it going
Usage would look like this: <HeadlessUICom _as=#div> ... </HeadlessUIComp>
Looks like HeadlessUI defines as as a union type (either "div" | ... | React.fragment). ReScript doesn’t support polymorphic values too well, so you need a helper module to unify these types.
Kinda like this:
type state
module As: {
type t
let fragment: t
let dom: [#div] => t
} = {
type t
@module("react")
external fragment: t = "Fragment"
external dom: [#div] => t = "%identity"
}
module MyComp = {
@module("@headlessui/react") @react.component
external make: (
~_as: As.t=?,
~className: string=?,
~children: state => React.element,
) => React.element = "Menu"
}
let _ = <MyComp _as=As.fragment> {(_) => <div/>} </MyComp>
let _ = <MyComp _as=As.dom(#div)> {(_) => <div/>} </MyComp>
The best way to debug this is to look at the JS output. Did your program actually compile and yield the JS output you’d expect? Does it look exactly like in the HeadlessUI docs and still doesn’t work?
Haha, my bindings for Dialog were fine…I must’ve copy pasted my binding for Dialog over to Transition because my Transition binding was going to “Dialog” which is why my error kept coming up as Dialog