Binding to functions that return and spread props as a function

Hey guys, looking for help on a binding.

Here is an example of a function that returns props spread with new props that I am not sure how to bind to nor do I know how to implement this in rescript.


Here is how the functions are used in JS:

<svg {...getCardImageProps({ images })} />
<input {...getCardNumberProps()} />

Thanks in advance!

You were able to get this working earlier, right?

Yup!

I was able to achieve this using the <Spread /> example component from reason-react.

@react.component
let make = (~props, ~children) => React.cloneElement(children, props);
<Spread
   props={getExpiryDateProps({
   onChange: handleChangeExp,
   onBlur: (_ => setExpState(_ => Dormant))->Some,
   onFocus: (_ => setExpState(_ => Active))->Some,
})}>
    <input value=state.exp />
</Spread>
2 Likes