Skip to content

Commit 4cc984c

Browse files
committed
Prepare jsx / jsxKeyed / ... for ppx v4 usage
1 parent a23495c commit 4cc984c

File tree

3 files changed

+82
-4
lines changed

3 files changed

+82
-4
lines changed

src/React.res

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ external cloneElement: (element, 'props) => element = "cloneElement"
2525
external createElementVariadic: (component<'props>, 'props, array<element>) => element =
2626
"createElement"
2727

28-
@module("react") @deprecated("Please use JSX syntax directly.")
28+
@module("react/jsx-runtime")
2929
external jsxKeyed: (component<'props>, 'props, string) => element = "jsx"
3030

31-
@module("react") @deprecated("Please use JSX syntax directly.")
31+
@module("react/jsx-runtime")
3232
external jsx: (component<'props>, 'props) => element = "jsx"
3333

34-
@module("react") @deprecated("Please use JSX syntax directly.")
34+
@module("react/jsx-runtime")
3535
external jsxs: (component<'props>, 'props) => element = "jsxs"
3636

37-
@module("react") @deprecated("Please use JSX syntax directly.")
37+
@module("react/jsx-runtime")
3838
external jsxsKeyed: (component<'props>, 'props, string) => element = "jsxs"
3939

4040
type ref<'value> = {mutable current: 'value}

test/v4-ppx/BasicComponent.res

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@@warning("-27")
2+
3+
module Test = {
4+
@bs.obj external makeProps: (~children: 'children, unit) => {"children": 'children} = ""
5+
let make =
6+
(@warning("-16") ~children) => {
7+
children
8+
}
9+
let make = {
10+
let \"Foo$Test" = (\"Props": {"children": 'children}) => make(~children=\"Props"["children"])
11+
\"Foo$Test"
12+
}
13+
}
14+
15+
module App = {
16+
@bs.obj external makeProps: unit => {.} = ""
17+
18+
let make = () => {
19+
(@warning("-3") React.jsx)(
20+
Test.make,
21+
{
22+
Test.makeProps(~children={React.string("help")}, ())
23+
},
24+
)
25+
}
26+
let make = {
27+
let \"Foo$App" = (\"Props": {.}) => make()
28+
\"Foo$App"
29+
}
30+
}

test/v4-ppx/KeyedComp.res

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@@warning("-27")
2+
3+
module Test = {
4+
@bs.obj external makeProps: (~children: 'children, unit) => {"children": 'children} = ""
5+
let make =
6+
(@warning("-16") ~children) => {
7+
children
8+
}
9+
let make = {
10+
let \"Foo$Test" = (\"Props": {"children": 'children}) => make(~children=\"Props"["children"])
11+
\"Foo$Test"
12+
}
13+
}
14+
15+
module App = {
16+
@bs.obj external makeProps: unit => {.} = ""
17+
18+
let make = () => {
19+
@warning("-3")
20+
React.jsxs(
21+
React.Fragment.make,
22+
React.Fragment.makeProps(
23+
~children=React.array([
24+
(@warning("-3") React.jsx)(
25+
Test.make,
26+
Test.makeProps(~children={React.string("help")}, ()),
27+
),
28+
(@warning("-3") React.jsxKeyed)(
29+
Test.make,
30+
Test.makeProps(~children={React.string("help")}, ()),
31+
"test",
32+
),
33+
]),
34+
(),
35+
),
36+
)
37+
}
38+
let make = {
39+
let \"Foo$App" = (\"Props": {.}) => make()
40+
\"Foo$App"
41+
}
42+
}
43+
44+
let element = <App/>
45+
46+
47+
ReactDOMServer.renderToString(element)->Js.log
48+

0 commit comments

Comments
 (0)