Skip to content

Missing mangling props name in JSX v4 #5904

Closed
@mununki

Description

@mununki

The internal representation of props has been changed to record in JSX v4. It causes the props names which are the same as the keyword are not mangled. Because the mangling is working for the object.

Not mangled prop names can be a problem in case of binding the js module that has props such as open or type.

There is a way to replace the prop name in the record with @as("..."). But, JSX v4 is dropping the attributes in the process of transformation.

module C0 = {
  @react.component
  let make =
    (@as("open") ~_open, @as("type") ~_type: string) => React.string(_open)
}
module C1 = {
  @react.component
  external make: (@as("open") ~_open: string, @as("type") ~_type: string) => React.element =
    "default"
}

let c0 = <C0 _open="x" _type="t" />
let c1 = <C1 _open="x" _type="t" />

transformed to:

var c0 = JsxRuntime.jsx(SignIn_Buyer$C0, {
      _open: "x", // supposed to be open
      _type: "t" // // supposed to be type
    });

var c1 = JsxRuntime.jsx(default, {
      _open: "x",
      _type: "t"
    });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions