You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/docs/manual/v11.0.0/jsx.mdx
+29-11Lines changed: 29 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -353,6 +353,8 @@ Below is a full list of everything you need in a generic JSX transform module, i
353
353
354
354
> You can easily copy-paste-and-adapt this to your needs if you're creating bindings to a JSX framework. Most often, all you'll need to change is what the `@module("") external` points to, so the runtime calls point to the correct JS module.
355
355
356
+
<CodeTablabels={["ReScript"]}>
357
+
356
358
```rescript
357
359
// Preact.res
358
360
/* Below is a number of aliases to the common `Jsx` module */
@@ -362,16 +364,16 @@ type component<'props> = Jsx.component<'props>
362
364
363
365
type componentLike<'props, 'return> = Jsx.componentLike<'props, 'return>
364
366
365
-
@module("preact")
367
+
@module("preact/jsx-runtime")
366
368
external jsx: (component<'props>, 'props) => element = "jsx"
external someElement: element => option<element> = "%identity"
416
419
}
417
420
```
418
421
422
+
</CodeTab>
423
+
419
424
As you can see, most of the things you'll want to implement will be copy paste from the above. But do note that **everything needs to be there unless explicitly noted** or the transform will fail at compile time.
425
+
426
+
To enable this, you need to configure the `jsx``module` in your `rescript.json`:
427
+
428
+
```json
429
+
{
430
+
"jsx": {
431
+
"version": 4,
432
+
"module": "Preact"
433
+
}
434
+
}
435
+
```
436
+
437
+
_value "Preact" is the name of the module that implements the generic JSX transform._
0 commit comments