Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

How to use Custom Components as Props in rescript

$
0
0

What worked for me is


let defaultDotProps = {
  onMove: _ => (),
  index: 0,
  carouselState: defaultStateCallBack,
  onClick: _ => (),
  active: false,
}
module CustomDots = {
  type props<'dotsProps> = {dotsProps: 'dotsProps}
  let make = props => {...}
}
<ReactMultiCarousel customDot={CustomDots.make} >children </ReactMultiCarousel>

in ReactMultiCarousel component

let customDot = customDot->Belt.Option.map(customDot => %raw(`JsxRuntime.jsx(customDot, {})`))
  <>
making  ~customDot: Jsx.element=?,

so I think what was happening was when passing element it was appling property to dom which will be div so instead of passing element we can passing jsx component and inside library we are already calling cloneElement to pass the required element so this worked
but I’m not sure about the correctness of this solution even though it worked
@tsnobip @mouton is there any better way for doing this?


Viewing all articles
Browse latest Browse all 2592

Trending Articles