Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new WebAPI #121

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 33 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@
"devDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rescript": "^11.0.0"
"rescript": "^12.0.0-alpha.5"
},
"peerDependencies": {
"react": ">=18.0.0",
"react-dom": ">=18.0.0"
},
"dependencies": {
"@rescript/webapi": "^0.1.0-experimental-82a7689"
}
}
5 changes: 4 additions & 1 deletion rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
"mode": "classic"
},
"sources": [{ "dir": "src", "subdirs": true }],
"package-specs": [{ "module": "commonjs", "in-source": true }],
"package-specs": [{ "module": "esmodule", "in-source": true }],
"suffix": ".bs.js",
"bs-dependencies": [
"@rescript/webapi"
],
"bs-dev-dependencies": [],
"bsc-flags": [],
"uncurried": false
Expand Down
46 changes: 22 additions & 24 deletions src/React.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions src/ReactDOM.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 14 additions & 11 deletions src/ReactDOM.res
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
calls and add the appropriate `require("react-dom")` in the file calling this `render` */

// Helper so that ReactDOM itself doesn't bring any runtime

open WebAPI

@val @return(nullable)
external querySelector: string => option<Dom.element> = "document.querySelector"
external querySelector: string => option<DOMAPI.element> = "document.querySelector"

@module("react-dom")
@deprecated(
"ReactDOM.render is no longer supported in React 18. Use ReactDOM.Client.createRoot instead."
)
external render: (React.element, Dom.element) => unit = "render"
external render: (React.element, DOMAPI.element) => unit = "render"

module Client = {
module Root = {
Expand All @@ -25,37 +28,37 @@ module Client = {
}

@module("react-dom/client")
external createRoot: Dom.element => Root.t = "createRoot"
external createRoot: DOMAPI.element => Root.t = "createRoot"

@module("react-dom/client")
external hydrateRoot: (Dom.element, React.element) => Root.t = "hydrateRoot"
external hydrateRoot: (DOMAPI.element, React.element) => Root.t = "hydrateRoot"
}

@module("react-dom")
@deprecated(
"ReactDOM.hydrate is no longer supported in React 18. Use ReactDOM.Client.hydrateRoot instead."
)
external hydrate: (React.element, Dom.element) => unit = "hydrate"
external hydrate: (React.element, DOMAPI.element) => unit = "hydrate"

@module("react-dom")
external createPortal: (React.element, Dom.element) => React.element = "createPortal"
external createPortal: (React.element, DOMAPI.element) => React.element = "createPortal"

@module("react-dom")
@deprecated(
"ReactDOM.unmountComponentAtNode is no longer supported in React 18. Use ReactDOM.Client.Root.unmount instead."
)
external unmountComponentAtNode: Dom.element => unit = "unmountComponentAtNode"
external unmountComponentAtNode: DOMAPI.element => unit = "unmountComponentAtNode"

external domElementToObj: Dom.element => {..} = "%identity"
external domElementToObj: DOMAPI.element => {..} = "%identity"

type style = ReactDOMStyle.t

type domRef = JsxDOM.domRef

module Ref = {
type t = domRef
type currentDomRef = React.ref<Js.nullable<Dom.element>>
type callbackDomRef = Js.nullable<Dom.element> => unit
type currentDomRef = React.ref<Js.nullable<DOMAPI.element>>
type callbackDomRef = Js.nullable<DOMAPI.element> => unit

external domRef: currentDomRef => domRef = "%identity"
external callbackDomRef: callbackDomRef => domRef = "%identity"
Expand All @@ -77,7 +80,7 @@ module Props = {
@optional
key: string,
@optional
ref: Js.nullable<Dom.element> => unit,
ref: Js.nullable<DOMAPI.element> => unit,
/* accessibility */
/* https://www.w3.org/TR/wai-aria-1.1/ */
/* https://accessibilityresources.org/<aria-tag> is a great resource for these */
Expand Down
7 changes: 4 additions & 3 deletions src/ReactDOMStyle.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 34 additions & 33 deletions src/ReactEvent.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading