Define .rei with React.forwardRef

Hi,

I didn’t found how to declare a .rei file when a React component use forwardRef. (note: I still use Reason syntax)

[@react.component]
let make = React.forwardRef((~id: string), ref_) => ...)

I tried something like this but no clue

[@react.component]
let make: (~id: string, ~ref_: 'ref) => React.element;

I think it’s the ppx react.component fault because of the magic with makeProps ?
ATM it will take me some times to replace this feature by a simple prop so if you have some ideas I’ll take it :slight_smile:

Thanks !

I think you can just use [@react.component] and leave out the ref (it’s an implicit prop).

It doesn’t work, I tried

[@react.component]
let make: (~id: string, ~ref_: 'ref) => React.element;
/* or */
[@react.component]
let make: (~id: string) => React.element;

But the makeProps error caught me
Capture d’écran 2021-04-07 à 09.09.05

Don’t add ref_ in the signature, it’s implicit for react components.

What’s the error message in the second case?

This is when I omit the ref_ props
Capture d’écran 2021-04-08 à 14.00.15

You can always drop out of the ppx and write makeProps by hand. Take a look at this example. It’s definitely not pretty because React refs disappear from the actual props object on the inside.