Skip to content

Commit 5d22d7f

Browse files
committed
fix jsx runtime import
1 parent 41249e4 commit 5d22d7f

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

src/Playground.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ module App = {
13791379
}
13801380
`
13811381

1382-
let since_10_1 = `@@jsxConfig({version: 4, mode: "classic"})
1382+
let since_10_1 = `@@jsxConfig({version: 4, mode: "automatic"})
13831383
13841384
module Button = {
13851385
@react.component

src/RenderPanel.res

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
let wrapReactApp = code =>
22
`(function () {
33
${code}
4-
if (!window.reactRoot){
5-
const container = document.getElementById("root");
6-
const root = ReactDOM.createRoot(container);
7-
window.reactRoot = root;
8-
}
94
const appContainer$$ = () => App.make();
105
window.reactRoot.render(appContainer$$());
116
})();`

src/common/EvalIFrame.res

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,26 @@ let srcDoc = `
1515
</head>
1616
<body>
1717
<div id="root"></div>
18+
<script type="importmap">
19+
{
20+
"imports": {
21+
"@jsxImportSource": "https://esm.sh/react@${reactVersion}",
22+
"react-dom/client": "https://esm.sh/react-dom@${reactVersion}/client",
23+
"react": "https://esm.sh/react@${reactVersion}",
24+
"react/jsx-runtime": "https://esm.sh/react@${reactVersion}/jsx-runtime"
25+
}
26+
}
27+
</script>
28+
<script type="module">
29+
import * as ReactDOM from 'react-dom/client';
30+
import * as React from 'react';
31+
import * as JsxRuntime from 'react/jsx-runtime';
32+
const container = document.getElementById("root");
33+
const root = ReactDOM.createRoot(container);
34+
window.reactRoot = root;
35+
window.React = React;
36+
window.JsxRuntime = JsxRuntime;
37+
</script>
1838
<script>
1939
window.addEventListener("message", (event) => {
2040
try {

0 commit comments

Comments
 (0)