Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 0fbf9a7

Browse files
committed
update jsx spec
1 parent 662f4b8 commit 0fbf9a7

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

cli/JSXV4.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ It produces a type definition and a new function.
4040
4141
// is converted to
4242
43-
type props<'x, 'y, 'z> = {x: 'x, @optional y: 'y, @optional z: 'z, @optional key: string}
43+
type props<'x, 'y, 'z> = {x: 'x, y?: 'y, z?: 'z}
4444
4545
({x, y, z}: props<_>) => {
4646
let y = switch props.y {
@@ -60,11 +60,11 @@ React.createElement(Comp.make, {x})
6060
6161
<Comp x y=7 ?z>
6262
// is converted to
63-
React.createElement(Comp.make, {x, y:7, @optional z})
63+
React.createElement(Comp.make, {x, y:7, ?z})
6464
6565
<Comp x key="7">
6666
// is converted to
67-
React.createElement(Comp.make, {x, key: "7"})
67+
React.createElement(Comp.make, Jsx.addKeyProp({x}, "7"))
6868
```
6969

7070
**New "jsx" transform**
@@ -76,16 +76,16 @@ The "jsx" transform affects component application but not the definition.
7676
```rescript
7777
<Comp x>
7878
// is converted to
79-
Js.React.jsx(Comp.make, {x})
79+
React.jsx(Comp.make, {x})
8080
```
8181

8282
```rescript
8383
<div name="div" />
8484
// is converted to
85-
Js.React.jsxDom("div", { name: "div" })
85+
ReactDOM.jsx("div", { name: "div" })
8686
```
8787

88-
The props type of dom elements, e.g. `div`, is inferred to `Js.React.domProps`.
88+
The props type of dom elements, e.g. `div`, is inferred to `ReactDOM.domProps`.
8989

9090
```rescript
9191
type domProps = {
@@ -102,7 +102,7 @@ type domProps = {
102102
103103
// is converted to
104104
105-
type props<'x, 'y, 'z> = {x: 'x, @optional y: 'y, @optional z: 'z}
105+
type props<'x, 'y, 'z> = {x: 'x, y?: 'y, z?: 'z}
106106
107107
props<int, int, int> => React.element
108108
```
@@ -121,7 +121,11 @@ function has the name of the enclosing module/file.
121121
122122
// is converted to
123123
124+
// v4
124125
ReactDOMRe.createElement(ReasonReact.fragment, [comp1, comp2, comp3])
126+
127+
// v4 @ new jsx transform
128+
React.jsxs(React.jsxFragment, {children: [comp1, comp2, comp3]})
125129
```
126130

127131
**File-level config**

0 commit comments

Comments
 (0)