Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing mangling props name in JSX v4 #5904

Closed
mununki opened this issue Dec 13, 2022 · 0 comments
Closed

Missing mangling props name in JSX v4 #5904

mununki opened this issue Dec 13, 2022 · 0 comments

Comments

@mununki
Copy link
Member

mununki commented Dec 13, 2022

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"
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant