Skip to content

Commit

Permalink
address code review items
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro committed Sep 18, 2023
1 parent e76e085 commit 84a4d83
Show file tree
Hide file tree
Showing 17 changed files with 982 additions and 541 deletions.
397 changes: 5 additions & 392 deletions src/React.re

Large diffs are not rendered by default.

538 changes: 447 additions & 91 deletions src/React.rei

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions src/context.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
type t('props);

[@mel.obj]
external makeProps:
(~value: 'props, ~children: Types.element, unit) =>
{
.
"value": 'props,
"children": Types.element,
};

[@mel.get]
external provider:
t('props) =>
Types.component({
.
"value": 'props,
"children": Types.element,
}) =
"Provider";
30 changes: 15 additions & 15 deletions src/dOM.re
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ external querySelector: string => option(Dom.element) =
"document.querySelector";

[@mel.module "react-dom"]
external render: (React0.element, Dom.element) => unit = "render";
external render: (Types.element, Dom.element) => unit = "render";

module Experimental = {
type root;
Expand All @@ -22,14 +22,14 @@ module Experimental = {
[@mel.module "react-dom"]
external createBlockingRoot: Dom.element => root = "createBlockingRoot";

[@mel.send] external render: (root, React0.element) => unit = "render";
[@mel.send] external render: (root, Types.element) => unit = "render";
};

[@mel.module "react-dom"]
external hydrate: (React0.element, Dom.element) => unit = "hydrate";
external hydrate: (Types.element, Dom.element) => unit = "hydrate";

[@mel.module "react-dom"]
external createPortal: (React0.element, Dom.element) => React0.element =
external createPortal: (Types.element, Dom.element) => Types.element =
"createPortal";

[@mel.module "react-dom"]
Expand All @@ -44,7 +44,7 @@ type domRef;

module Ref = {
type t = domRef;
type currentDomRef = React0.ref(Js.nullable(Dom.element));
type currentDomRef = Types.ref(Js.nullable(Dom.element));
type callbackDomRef = Js.nullable(Dom.element) => unit;

external domRef: currentDomRef => domRef = "%identity";
Expand All @@ -63,7 +63,7 @@ type domProps = {
[@mel.optional]
ref: option(domRef),
[@mel.optional]
children: option(React0.element),
children: option(Types.element),
/* accessibility */
/* https://www.w3.org/TR/wai-aria-1.1/ */
[@mel.optional] [@mel.as "aria-activedescendant"]
Expand Down Expand Up @@ -1086,32 +1086,32 @@ type domProps = {
};

// As we've removed `ReactDOMRe.createElement`, this enables patterns like
// React0.createElement(ReactDOM.stringToComponent(multiline ? "textarea" : "input"), ...)
external stringToComponent: string => React0.component(domProps) =
"%identity";
// Types.createElement(ReactDOM.stringToComponent(multiline ? "textarea" : "input"), ...)
external stringToComponent: string => Types.component(domProps) = "%identity";

module Style = DOMStyle;
module Server = DOMServer;

[@mel.variadic] [@mel.module "react"]
external createElement:
(string, ~props: domProps=?, array(React0.element)) => React0.element =
(string, ~props: domProps=?, array(Types.element)) => Types.element =
"createElement";

[@mel.variadic] [@mel.module "react"]
external createDOMElementVariadic:
(string, ~props: domProps=?, array(React0.element)) => React0.element =
(string, ~props: domProps=?, array(Types.element)) => Types.element =
"createElement";

[@mel.module "react/jsx-runtime"]
external jsxKeyed: (string, domProps, ~key: string=?, unit) => React0.element =
external jsxKeyed: (string, domProps, ~key: string=?, unit) => Types.element =
"jsx";

[@mel.module "react/jsx-runtime"]
external jsx: (string, domProps) => React0.element = "jsx";
external jsx: (string, domProps) => Types.element = "jsx";

[@mel.module "react/jsx-runtime"]
external jsxs: (string, domProps) => React0.element = "jsxs";
external jsxs: (string, domProps) => Types.element = "jsxs";

[@mel.module "react/jsx-runtime"]
external jsxsKeyed: (string, domProps, ~key: string=?, unit) => React0.element =
external jsxsKeyed: (string, domProps, ~key: string=?, unit) => Types.element =
"jsxs";
4 changes: 2 additions & 2 deletions src/dOMServer.re
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[@mel.module "react-dom/server"]
external renderToString: React0.element => string = "renderToString";
external renderToString: Types.element => string = "renderToString";

[@mel.module "react-dom/server"]
external renderToStaticMarkup: React0.element => string =
external renderToStaticMarkup: Types.element => string =
"renderToStaticMarkup";
3 changes: 2 additions & 1 deletion src/errorBoundary.re
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ type params('error) = {
|}
];

module React = React0;
module React = Types;

[@react.component]
external make:
(~children: React.element, ~fallback: params('error) => React.element) =>
Expand Down
Loading

0 comments on commit 84a4d83

Please sign in to comment.