How to bind react component with default value(not string)?

below is the code that binds the react component.

module Content = {
 @module("@radix-ui/react-dialog") @react.component
 external make: (
   ~children: React.element,
   ~className: string=?,
   ~ref: ReactDOM.Ref.t=?,
   ~onPointerDownOutside: ReactEvent.Mouse.t => unit=?,
   ~onOpenAutoFocus: ReactEvent.Pointer.t => unit=?,
 ) => React.element = "Content"
}

And here’s the code I want to apply the default value.

module Content = {
 @module("@radix-ui/react-dialog") @react.component
 external make: (
   ~children: React.element,
   ~className: string=?,
   ~ref: ReactDOM.Ref.t=?,
   ~onPointerDownOutside: ReactEvent.Mouse.t => unit=?,
   ~onOpenAutoFocus: ReactEvent.Pointer.t => unit={ReactEvent.Synthetic.preventDefault},
 ) => React.element = "Content"
}

I used code like

@as(json`{ onOpenAutoFocus : e => e.preventDefault() }`) _ 

to apply the default value, but it didn’t work. :frowning:

I think binding(interop) is just an interface, so you need to write an implementation with it. There you can pass the default value to the props.

2 Likes