Hi all
I have a typescript react component , one of its props accepts function/class component, ,
I have written rescript react bindings for it.
My attempts in passing such a prop from rescript side
Definition of listitem
module ListItem = {
@genType.import(("./List", "ListItem")) @react.component
external make: (
~icon: React.component<
{
"type": option<Icon.Icon.iconType>,
"className": option<string>,
"domRef": option<Icon.reactSvgElementRef_>,
"label": option<string>,
"onDarkBg": option<bool>,
"size": option<Icon.Icon.iconSizeType>,
}>=?,
~onClick: unit => unit=?,
) => React.element = "ListItem"
}
Icon module definition on rescript side
module Icon = {
@genType.import(("icons", "Icon")) @react.component
external make: (
~size: iconSizeType=?,
~className: string=?,
~domRef: reactSvgElementRef_=?,
~label: string=?,
~onDarkBg: bool=?,
~\"type": iconType=?,
) => React.element = "Icon"
}
}
Usage on the rescript side
<ListItem key={Belt.Int.toString(i)} onClick={onClick} icon={Icon.make}>
This seems to satisfy the rescript compiler atleast
Js output
React.createElement(ListItem.make, {
icon: Icon.make,
onClick: onClick,
children: service.name.valueDefault,
key: String(i)
})
But the js side is not able to resolve it properly, I mean its treating the passed rescript react component as Dom elements, getting the following errors
index.js:1 Warning: React does not recognize the `titleProps` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `titleprops` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
Found documentation Component Types but no sample implementation found
Thanks for your help