-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:/reasonml/reason-react into 19
* 'main' of github.com:/reasonml/reason-react: Remove raise annotations and fix locations on errors (#863) ppx: support "custom children" in uppercase components without having to wrap in array literal (#823)
- Loading branch information
Showing
16 changed files
with
288 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module X_as_main_function = { | ||
[@react.component] | ||
let x = () => <div />; | ||
}; | ||
|
||
module Create_element_as_main_function = { | ||
[@react.component] | ||
let createElement = (~lola) => <div> {React.string(lola)} </div>; | ||
}; | ||
|
||
/* This isn't valid running code, since Foo gets transformed into Foo.make, not createElement. */ | ||
module Invalid_case = { | ||
[@react.component] | ||
let make = (~lola) => { | ||
<Create_element_as_main_function lola />; | ||
}; | ||
}; | ||
|
||
/* If main function is not make, neither createElement, then it can be explicitly annotated */ | ||
/* NOTE: If you use `createElement` refmt removes it */ | ||
module Valid_case = { | ||
[@react.component] | ||
let make = () => { | ||
<Component_with_x_as_main_function.x />; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
Since we generate invalid syntax for the argument of the make fn `(Props : <>)` | ||
We need to output ML syntax here, otherwise refmt could not parse it. | ||
$ ../ppx.sh --output ml input.re | ||
module X_as_main_function = | ||
struct | ||
external xProps : ?key:string -> unit -> < > Js.t = ""[@@mel.obj ] | ||
let x () = ReactDOM.jsx "div" (((ReactDOM.domProps)[@merlin.hide ]) ()) | ||
let x = | ||
let Output$X_as_main_function$x (Props : < > Js.t) = x () in | ||
Output$X_as_main_function$x | ||
end | ||
module Create_element_as_main_function = | ||
struct | ||
external createElementProps : | ||
lola:'lola -> ?key:string -> unit -> < lola: 'lola > Js.t = "" | ||
[@@mel.obj ] | ||
let createElement = | ||
((fun ~lola -> | ||
ReactDOM.jsx "div" | ||
(((ReactDOM.domProps)[@merlin.hide ]) | ||
~children:(React.string lola) ())) | ||
[@warning "-16"]) | ||
let createElement = | ||
let Output$Create_element_as_main_function$createElement | ||
(Props : < lola: 'lola > Js.t) = | ||
createElement ~lola:(Props ## lola) in | ||
Output$Create_element_as_main_function$createElement | ||
end | ||
module Invalid_case = | ||
struct | ||
external makeProps : | ||
lola:'lola -> ?key:string -> unit -> < lola: 'lola > Js.t = "" | ||
[@@mel.obj ] | ||
let make = | ||
((fun ~lola -> | ||
React.jsx Create_element_as_main_function.make | ||
(Create_element_as_main_function.makeProps ~lola ())) | ||
[@warning "-16"]) | ||
let make = | ||
let Output$Invalid_case (Props : < lola: 'lola > Js.t) = | ||
make ~lola:(Props ## lola) in | ||
Output$Invalid_case | ||
end | ||
module Valid_case = | ||
struct | ||
external makeProps : ?key:string -> unit -> < > Js.t = ""[@@mel.obj ] | ||
let make () = | ||
React.jsx Component_with_x_as_main_function.x | ||
(Component_with_x_as_main_function.xProps ()) | ||
let make = | ||
let Output$Valid_case (Props : < > Js.t) = make () in | ||
Output$Valid_case | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.