Skip to content

Commit 8f6f928

Browse files
committed
feat(react-dom): add experimental module
list of experimental bind: * preconnect * prefetchDNS * preinit * preinitModule * preload * preloadModule
1 parent 15affd0 commit 8f6f928

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

src/ReactDOM.re

+27
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,33 @@ external unmountComponentAtNode: Dom.element => unit =
477477
[@mel.module "react-dom"]
478478
external flushSync: (unit => unit) => unit = "flushSync";
479479

480+
module Experimental = {
481+
[@deriving jsProperties]
482+
type preOptions = {
483+
[@mel.as "as"] [@mel.optional]
484+
_as: option([ | `script]),
485+
[@mel.optional]
486+
crossOrigin: option(string),
487+
[@mel.optional]
488+
integrity: option(string),
489+
[@mel.optional]
490+
nonce: option(string),
491+
};
492+
493+
[@mel.module "react-dom"]
494+
external preconnect: string => unit = "preconnect";
495+
[@mel.module "react-dom"]
496+
external prefetchDNS: string => unit = "prefetchDNS";
497+
[@mel.module "react-dom"]
498+
external preinit: string => unit = "preinit";
499+
[@mel.module "react-dom"]
500+
external preinitModule: (string, ~options: preOptions=?, unit) => unit = "preinitModule";
501+
[@mel.module "react-dom"]
502+
external preload: string => unit = "preload";
503+
[@mel.module "react-dom"]
504+
external preloadModule: (string, ~options: preOptions=?, unit) => unit = "preloadModule";
505+
}
506+
480507
external domElementToObj: Dom.element => Js.t({..}) = "%identity";
481508

482509
type style = Style.t;

src/ReactDOM.rei

+45
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,51 @@ external unmountComponentAtNode: Dom.element => unit =
478478
[@mel.module "react-dom"]
479479
external flushSync: (unit => unit) => unit = "flushSync";
480480

481+
module Experimental: {
482+
/*
483+
preinitModule and preloadModule options.
484+
https://react.dev/reference/react-dom/preinitModule#parameters
485+
*/
486+
[@deriving jsProperties]
487+
type preOptions = {
488+
/* a required string. It must be 'script'. */
489+
[@mel.as "as"] [@mel.optional]
490+
_as: option([ | `script]),
491+
/*
492+
a required string. It must be "anonymous", "use-credentials", and "".
493+
https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin
494+
*/
495+
[@mel.optional]
496+
crossOrigin: option(string),
497+
/*
498+
a string. A cryptographic hash of the module, to verify its authenticity.
499+
https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
500+
*/
501+
[@mel.optional]
502+
integrity: option(string),
503+
/*
504+
a string. A cryptographic nonce to allow the module when using a strict Content Security Policy.
505+
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce
506+
*/
507+
[@mel.optional]
508+
nonce: option(string),
509+
};
510+
511+
/* This module is used to bind to APIs for future versions of ReactDOM. There is no guarantee of backwards compatibility or stability. */
512+
[@mel.module "react-dom"]
513+
external preconnect: string => unit = "preconnect";
514+
[@mel.module "react-dom"]
515+
external prefetchDNS: string => unit = "prefetchDNS";
516+
[@mel.module "react-dom"]
517+
external preinit: string => unit = "preinit";
518+
[@mel.module "react-dom"]
519+
external preinitModule: (string, ~options: preOptions=?, unit) => unit = "preinitModule";
520+
[@mel.module "react-dom"]
521+
external preload: string => unit = "preload";
522+
[@mel.module "react-dom"]
523+
external preloadModule: (string, ~options: preOptions=?, unit) => unit = "preloadModule";
524+
}
525+
481526
external domElementToObj: Dom.element => Js.t({..}) = "%identity";
482527

483528
type style = Style.t;

0 commit comments

Comments
 (0)