rescript-lang.org icon indicating copy to clipboard operation
rescript-lang.org copied to clipboard

Need better documentation on using ~_type in React

Open jmagaram opened this issue 4 years ago • 0 comments

I'm trying to bind to a React component that uses type=... and couldn't figure out how to do it. The correct answer - at least this works for me - is to use ~_type: string The documentation at https://rescript-lang.org/docs/react/latest/components-and-props#handling-invalid-prop-names-eg-keywords seems to say to use something like <input type_="text" /> with the underscore following the property name. This is exceptionally confusing. See related issue at https://forum.rescript-lang.org/t/how-to-bind-to-react-component-with-parameter-named-type/2471/3

I think the documentation around underscores on names and how to use keywords needs to be cleaned up. I also couldn't figure out why @as("type") didn't work.

@module("react-rewards") @react.component
external make: (
  ~ref: ReactDOM.domRef=?,
  ~children: React.element=?,
  ~config: config=?,
  ~_type: [#confetti | #emoji | #memphis]=?,
  unit,
) => React.element = "default"

jmagaram avatar Oct 04 '21 15:10 jmagaram