How to use label?


#1

I have the following code:

let make = (_children) => {
  ...component,
  initialState: () => {empty: ""},
  reducer: (_action: action, _state: state) => ReasonReact.NoUpdate,
  render: _self => {
    <div className="field">
      <input className="is-checkradio" id="exampleCheckbox" _type="checkbox" name="exampleCheckbox" />
      <label for_="exampleCheckbox">{ReasonReact.stringToElement("Hello!")}</label> 
    </div>
  },
};

The compiler complains:

The function applied to this argument has type
    (~key: string=?, ~ref: Js.nullable(Dom.element) => unit=?,
    ~defaultChecked: Js.boolean=?, ~defaultValue: string=?,  

It complains about for_="exampleCheckbox".

What am I doing wrong?

Thanks


#2

You need to replace “for_” with “htmlFor”. Unfortunately the error message is bad in this case and the suggested replacement doesn’t work. If you look at the source in ReactDOMRe.re you can see the allowed props. I’ll pop an issue on to the reasonML github on this.

Working here: Example