Rename type_ in binding

I’m having a small problem renaming type_ to type in a binding to Formik.

My binding looks like this:

module Field = {
  @module("formik") @react.component
  external make: (
    ~id: string,
    ~name: string,
    ~placeholder: string,
    @as("type") ~type_: string=?,
  ) => React.element = "Field"
}

And I thought the optional type_ would become type in the binding.
But the generated html still has a type_ field.

What do I need to change here? :thinking:

This particular scenario is a little funky.

For @react.component props, you need to name it ~_type:

module Field = {
  @module("formik") @react.component
  external make: (
    ~_type: string=?,
  ) => React.element = "Field"
}

let a = <Field _type="test"/>

This will compile to:

var React = require("react");
var Formik = require("formik");

var Field = {};

var a = React.createElement(Formik.Field, {
      type: "test"
    });

exports.Field = Field;
exports.a = a;
1 Like

Nice, thank you! That works :clap::clap::clap: