reasonml / reason-react

Reason bindings for ReactJS
https://reasonml.github.io/reason-react/
MIT License
3.25k stars 347 forks source link

Fragment + new jsx transform #834

Closed tatchi closed 3 months ago

tatchi commented 3 months ago

Given the following code

const App = () => <>hello</>

And using the new jsx transform, babel compiles it down to (link)

import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
const App = () => /*#__PURE__*/_jsx(_Fragment, {
  children: "hello"
});

While reason-react still uses React.createElement (playground)

// Generated by Melange

import * as React from "react";
import * as JsxRuntime from "react/jsx-runtime";

function _none_(Props) {
  return React.createElement(JsxRuntime.Fragment, undefined, "hello");
}

const make = _none_;

export {
  make ,
}
/* react Not a pure module */
davesnx commented 3 months ago

Indeed, probably best to use jsx function from jsx-runtime.

I will look into it soon, thanks for reporting!

jchavarri commented 3 months ago

I think this issue can be closed now (thanks @tatchi !)