Skip to content

Conversation

@nojaf
Copy link
Member

@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.

@pkg-pr-new
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
Member

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