Skip to content

Commit 13c28a2

Browse files
committed
update new jsx transform apis with Jsx module
1 parent 0f74265 commit 13c28a2

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

src/React.res

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
type element
1+
type element = Jsx.element
22

3-
@val external null: element = "null"
3+
let null = Jsx.null
44

5-
external float: float => element = "%identity"
6-
external int: int => element = "%identity"
7-
external string: string => element = "%identity"
5+
let float = Jsx.float
6+
let int = Jsx.int
7+
let string = Jsx.string
88

9-
external array: array<element> => element = "%identity"
9+
let array = Jsx.array
1010

11-
type componentLike<'props, 'return> = 'props => 'return
11+
type componentLike<'props, 'return> = Jsx.componentLike<'props, 'return>
1212

13-
type component<'props> = componentLike<'props, element>
13+
type component<'props> = Jsx.component<'props>
1414

15-
/* this function exists to prepare for making `component` abstract */
16-
external component: componentLike<'props, element> => component<'props> = "%identity"
15+
let component = Jsx.component
1716

1817
@module("react")
1918
external createElement: (component<'props>, 'props) => element = "createElement"
@@ -25,18 +24,20 @@ external cloneElement: (element, 'props) => element = "cloneElement"
2524
external createElementVariadic: (component<'props>, 'props, array<element>) => element =
2625
"createElement"
2726

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

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

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

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

39+
@module("react/jsx-runtime") external jsxFragment: element = "Fragment"
40+
4041
type ref<'value> = {mutable current: 'value}
4142

4243
module Ref = {

src/ReactDOM.res

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ external domElementToObj: Dom.element => {..} = "%identity"
3737

3838
type style = ReactDOMStyle.t
3939

40-
type domRef
40+
type domRef = JsxDOM.domRef
4141

4242
module Ref = {
4343
type t = domRef
@@ -2102,8 +2102,20 @@ module Props = {
21022102

21032103
include Props
21042104

2105+
@module("react/jsx-runtime")
2106+
external jsxKeyed: (string, JsxDOM.domProps, string) => Jsx.element = "jsx"
2107+
2108+
@module("react/jsx-runtime")
2109+
external jsx: (string, JsxDOM.domProps) => Jsx.element = "jsx"
2110+
2111+
@module("react/jsx-runtime")
2112+
external jsxs: (string, JsxDOM.domProps) => Jsx.element = "jsxs"
2113+
2114+
@module("react/jsx-runtime")
2115+
external jsxsKeyed: (string, JsxDOM.domProps, string) => Jsx.element = "jsxs"
2116+
21052117
// As we've removed `ReactDOMRe.createElement`, this enables patterns like
21062118
// React.createElement(ReactDOM.stringToComponent(multiline ? "textarea" : "input"), ...)
2107-
external stringToComponent: string => React.component<domProps> = "%identity"
2119+
external stringToComponent: string => React.component<JsxDOM.domProps> = "%identity"
21082120

21092121
module Style = ReactDOMStyle

src/ReactEvent.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
type synthetic<'a>
1+
type synthetic<'a> = JsxEvent.synthetic<'a>
22

33
module MakeEventWithType = (
44
Type: {

0 commit comments

Comments
 (0)