Skip to content

Add @react.componentWithProps to MyWeirdComponent test #7437

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

Merged
merged 1 commit into from
May 8, 2025

Conversation

nojaf
Copy link
Collaborator

@nojaf nojaf commented May 7, 2025

I am slowly coming to terms with the potential limitation of the preserve-jsx feature, which may require @react.component or @react.componentWithProps.

Copy link

pkg-pr-new bot commented May 7, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7437

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7437

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7437

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7437

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7437

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7437

commit: 637ffaf

@zth
Copy link
Collaborator

zth commented May 8, 2025

Yeah enforcing the @react.xx attribute sounds like a very reasonable requirement for preserve mode.

I think you in theory can also do this if you need the uppercase name:

  let \"MyWeirdComponent" = props =>
    <p>
      {React.string("foo")}
      {React.string(props.\"MyWeirdProp")}
    </p>
  
  let make = \"MyWeirdComponent"

That gives me this in the playground (without preserve mode though, so might be worth adding as a test as well):

function MyWeirdComponent(props) {
  return JsxRuntime.jsxs("p", {
    children: [
      "foo",
      props["\\\"MyWeirdProp\""]
    ]
  });
}

let MyWeirdComponent$1 = {
  MyWeirdComponent: MyWeirdComponent,
  make: MyWeirdComponent
};

let _escaped_jsx_prop = JsxRuntime.jsx(MyWeirdComponent, {
  MyWeirdProp: "bar"
});

@nojaf nojaf merged commit 39de4dc into rescript-lang:master May 8, 2025
21 checks passed
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

Successfully merging this pull request may close these issues.

3 participants