Skip to content

Commit

Permalink
Re-organise the modules (#794)
Browse files Browse the repository at this point in the history
  • Loading branch information
davesnx authored Oct 13, 2023
1 parent 76d5ea8 commit 3ab8747
Show file tree
Hide file tree
Showing 39 changed files with 3,513 additions and 3,543 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
in [#786](https://github.com/reasonml/reason-react/pull/786))
* Wrap the `React` library, exposing just a single top-level module
(@anmonteiro in [#783](https://github.com/reasonml/reason-react/pull/783))
* Re-organise toplevel modules (@davesnx in [#794](https://github.com/reasonml/reason-react/pull/794))

# 0.12.0

Expand Down
6 changes: 3 additions & 3 deletions ppx/reason_react_ppx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ module Binding = struct
let createElement ~loc ~attrs element children =
Builder.pexp_apply ~loc ~attrs
(Builder.pexp_ident ~loc
{ loc; txt = Ldot (Ldot (Lident "React", "DOM"), "createElement") })
{ loc; txt = Ldot (Lident "ReactDOM", "createElement") })
[ (nolabel, element); (nolabel, children) ]

let domProps ~applyLoc ~loc props =
Builder.pexp_apply ~loc:applyLoc
(Builder.pexp_ident ~loc:applyLoc ~attrs:merlinHideAttrs
{ loc; txt = Ldot (Ldot (Lident "React", "DOM"), "domProps") })
{ loc; txt = Ldot (Lident "ReactDOM", "domProps") })
props
end
end
Expand Down Expand Up @@ -478,7 +478,7 @@ let jsxExprAndChildren ~ident ~loc ~ctxt mapper ~keyProps children =
let reactJsxExprAndChildren = jsxExprAndChildren ~ident:(Lident "React")

let reactDomJsxExprAndChildren =
jsxExprAndChildren ~ident:(Ldot (Lident "React", "DOM"))
jsxExprAndChildren ~ident:(Lident "ReactDOM")

(* Builds an AST node for the entire `external` definition of props *)
let makeExternalDecl fnName loc namedArgListWithKeyAndRef namedTypeList =
Expand Down
50 changes: 25 additions & 25 deletions ppx/test/component.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ We need to output ML syntax here, otherwise refmt could not parse it.
[@@mel.obj ]
let make =
((fun ~lola ->
React.DOM.jsx "div"
(((React.DOM.domProps)[@merlin.hide ])
ReactDOM.jsx "div"
(((ReactDOM.domProps)[@merlin.hide ])
~children:(React.string lola) ()))
[@warning "-16"])
let make =
Expand All @@ -27,9 +27,9 @@ We need to output ML syntax here, otherwise refmt could not parse it.
""[@@mel.obj ]
let make =
((fun ?(name= "") ->
React.DOM.createElement React.jsxFragment
[|(React.DOM.jsx "div"
(((React.DOM.domProps)[@merlin.hide ])
ReactDOM.createElement React.jsxFragment
[|(ReactDOM.jsx "div"
(((ReactDOM.domProps)[@merlin.hide ])
~children:(React.string ("First " ^ name)) ()));(
React.jsx Hello.make
(Hello.makeProps ~children:(React.string ("2nd " ^ name))
Expand All @@ -51,8 +51,8 @@ We need to output ML syntax here, otherwise refmt could not parse it.
let make =
((fun ~children ->
((fun ~buttonRef ->
React.DOM.jsx "button"
(((React.DOM.domProps)[@merlin.hide ]) ~children
ReactDOM.jsx "button"
(((ReactDOM.domProps)[@merlin.hide ]) ~children
~ref:buttonRef ~className:"FancyButton" ()))
[@warning "-16"]))
[@warning "-16"])
Expand All @@ -76,8 +76,8 @@ We need to output ML syntax here, otherwise refmt could not parse it.
((fun ~name ->
((fun ?isDisabled ->
let onClick event = Js.log event in
React.DOM.jsx "button"
(((React.DOM.domProps)[@merlin.hide ]) ~name ~onClick
ReactDOM.jsx "button"
(((ReactDOM.domProps)[@merlin.hide ]) ~name ~onClick
~disabled:isDisabled ()))
[@warning "-16"]))
[@warning "-16"])
Expand All @@ -94,8 +94,8 @@ We need to output ML syntax here, otherwise refmt could not parse it.
""[@@mel.obj ]
let make =
((fun ?(name= "joe") ->
React.DOM.jsx "div"
(((React.DOM.domProps)[@merlin.hide ])
ReactDOM.jsx "div"
(((ReactDOM.domProps)[@merlin.hide ])
~children:((Printf.sprintf "`name` is %s" name) |>
React.string) ()))
[@warning "-16"])
Expand All @@ -117,37 +117,37 @@ We need to output ML syntax here, otherwise refmt could not parse it.
let make =
((fun ~children ->
((fun ~moreProps ->
React.DOM.jsxs "html"
(((React.DOM.domProps)[@merlin.hide ])
ReactDOM.jsxs "html"
(((ReactDOM.domProps)[@merlin.hide ])
~children:(React.array
[|(React.DOM.jsx "head"
(((React.DOM.domProps)[@merlin.hide ])
~children:(React.DOM.jsx "title"
(((React.DOM.domProps)
[|(ReactDOM.jsx "head"
(((ReactDOM.domProps)[@merlin.hide ])
~children:(ReactDOM.jsx "title"
(((ReactDOM.domProps)
[@merlin.hide ])
~children:(React.string
("SSR React "
^
moreProps))
())) ()));(React.DOM.jsxs
())) ()));(ReactDOM.jsxs
"body"
(((React.DOM.domProps)
(((ReactDOM.domProps)
[@merlin.hide
])
~children:(
React.array
[|(
React.DOM.jsx
ReactDOM.jsx
"div"
(((React.DOM.domProps)
(((ReactDOM.domProps)
[@merlin.hide
])
~children
~id:"root"
()));(
React.DOM.jsx
ReactDOM.jsx
"script"
(((React.DOM.domProps)
(((ReactDOM.domProps)
[@merlin.hide
])
~src:"/static/client.js"
Expand All @@ -170,8 +170,8 @@ We need to output ML syntax here, otherwise refmt could not parse it.
]
let make =
((fun ~children ->
React.DOM.jsx "div"
(((React.DOM.domProps)[@merlin.hide ]) ~children
ReactDOM.jsx "div"
(((ReactDOM.domProps)[@merlin.hide ]) ~children
~ariaHidden:"true" ()))
[@warning "-16"])
let make =
Expand Down
14 changes: 7 additions & 7 deletions ppx/test/fragment.t/run.t
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
$ ../ppx.sh --output re input.re
let fragment = foo =>
[@bla] React.DOM.createElement(React.jsxFragment, [|foo|]);
[@bla] ReactDOM.createElement(React.jsxFragment, [|foo|]);
let poly_children_fragment = (foo, bar) =>
React.DOM.createElement(React.jsxFragment, [|foo, bar|]);
ReactDOM.createElement(React.jsxFragment, [|foo, bar|]);
let nested_fragment = (foo, bar, baz) =>
React.DOM.createElement(
ReactDOM.createElement(
React.jsxFragment,
[|foo, React.DOM.createElement(React.jsxFragment, [|bar, baz|])|],
[|foo, ReactDOM.createElement(React.jsxFragment, [|bar, baz|])|],
);
let nested_fragment_with_lower = foo =>
React.DOM.createElement(
ReactDOM.createElement(
React.jsxFragment,
[|
React.DOM.jsx(
ReactDOM.jsx(
"div",
([@merlin.hide] React.DOM.domProps)(~children=foo, ()),
([@merlin.hide] ReactDOM.domProps)(~children=foo, ()),
),
|],
);
2 changes: 1 addition & 1 deletion ppx/test/functor.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ We need to output ML syntax here, otherwise refmt could not parse it.
((fun ~a ->
((fun ~b ->
print_endline "This function should be named `Test$Func`" M.x;
React.DOM.jsx "div" (((React.DOM.domProps)[@merlin.hide ]) ()))
ReactDOM.jsx "div" (((ReactDOM.domProps)[@merlin.hide ]) ()))
[@warning "-16"]))
[@warning "-16"])
let make =
Expand Down
36 changes: 18 additions & 18 deletions ppx/test/issue-429.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ First child `button`
"line": 35,
"col": 9
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down Expand Up @@ -422,7 +422,7 @@ First child `onClick` prop
"line": 30,
"col": 75
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down Expand Up @@ -482,7 +482,7 @@ First child `onClick` prop
"line": 35,
"col": 9
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down Expand Up @@ -573,7 +573,7 @@ First child `onClick` callback argument (event)
"line": 30,
"col": 75
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down Expand Up @@ -633,7 +633,7 @@ First child `onClick` callback argument (event)
"line": 35,
"col": 9
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down Expand Up @@ -748,7 +748,7 @@ First child `onClick` prop `dispatch`
"line": 30,
"col": 75
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down Expand Up @@ -808,7 +808,7 @@ First child `onClick` prop `dispatch`
"line": 35,
"col": 9
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down Expand Up @@ -935,7 +935,7 @@ First child `onClick` prop `Click`
"line": 30,
"col": 75
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down Expand Up @@ -995,7 +995,7 @@ First child `onClick` prop `Click`
"line": 35,
"col": 9
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down Expand Up @@ -1098,7 +1098,7 @@ First child `string`
"line": 30,
"col": 75
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down Expand Up @@ -1158,7 +1158,7 @@ First child `string`
"line": 35,
"col": 9
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down Expand Up @@ -1261,7 +1261,7 @@ First child `message`
"line": 30,
"col": 75
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down Expand Up @@ -1321,7 +1321,7 @@ First child `message`
"line": 35,
"col": 9
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down Expand Up @@ -1460,7 +1460,7 @@ Third child `state`
"line": 35,
"col": 9
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down Expand Up @@ -1599,7 +1599,7 @@ Third child `show` in `state.show`
"line": 35,
"col": 9
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down Expand Up @@ -1738,7 +1738,7 @@ Third child `string`
"line": 35,
"col": 9
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down Expand Up @@ -1877,7 +1877,7 @@ Third child `greeting`
"line": 35,
"col": 9
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down Expand Up @@ -2004,7 +2004,7 @@ Third child `null`
"line": 35,
"col": 9
},
"type": "React.DOM.domProps",
"type": "ReactDOM.domProps",
"tail": "no"
},
{
Expand Down
8 changes: 4 additions & 4 deletions ppx/test/location.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@
(Pexp_apply
((pexp_desc
(Pexp_ident
((txt (Ldot (Ldot (Lident React) DOM) jsx))
((txt (Ldot (Lident ReactDOM) jsx))
(loc
((loc_start
((pos_fname output.ml) (pos_lnum 1) (pos_bol 0)
Expand Down Expand Up @@ -726,7 +726,7 @@
(Pexp_apply
((pexp_desc
(Pexp_ident
((txt (Ldot (Ldot (Lident React) DOM) domProps))
((txt (Ldot (Lident ReactDOM) domProps))
(loc
((loc_start
((pos_fname output.ml) (pos_lnum 1) (pos_bol 0)
Expand Down Expand Up @@ -1669,7 +1669,7 @@
(Pexp_apply
((pexp_desc
(Pexp_ident
((txt (Ldot (Ldot (Lident React) DOM) jsx))
((txt (Ldot (Lident ReactDOM) jsx))
(loc
((loc_start
((pos_fname output.ml) (pos_lnum 5) (pos_bol 256)
Expand Down Expand Up @@ -1713,7 +1713,7 @@
(Pexp_apply
((pexp_desc
(Pexp_ident
((txt (Ldot (Ldot (Lident React) DOM) domProps))
((txt (Ldot (Lident ReactDOM) domProps))
(loc
((loc_start
((pos_fname output.ml) (pos_lnum 5)
Expand Down
Loading

0 comments on commit 3ab8747

Please sign in to comment.