How to pass a reserved keyword as a prop in reason-react


#1

I am trying to use rimble-ui ui-library, and one of the props that a button takes is called “as”. This is unfortunately a reserved word in reason. So I don’t know how to use this component in my reason-react app.

Here are the docs for the library.

This is my code:

[@bs.module "rimble-ui"] [@react.component]
external make:
  (~as_: string, ~href: string, ~target: string, ~children: React.element) =>
  React.element =
  "Button";

I’d like a way to replace the _as with ‘as’ as a prop name.


#2

https://stackoverflow.com/q/56820477/3103033 <- posted on SO, I think it is good to get more reason questions on there.

The answer has been posted on SO :slight_smile:


#3

It’s good you posted it on SO, we do need more visibility there.
About the answer itself, I’ve always found weird bucklescript uses a prefix underscore for that when it’s already used for unused variables, a postfix underscore would have been less confusing in my opinion.