diff --git a/src/React.re b/src/React.re index 45071cda2..60c9bc280 100644 --- a/src/React.re +++ b/src/React.re @@ -879,4 +879,9 @@ module Experimental = { /* This module is used to bind to APIs for future versions of React. There is no guarantee of backwards compatibility or stability. */ [@mel.module "react"] external use: Js.Promise.t('a) => 'a = "use"; + + [@mel.module "react"] + external useOptimistic: + ('state, ('state, 'a) => 'state) => ('state, 'a => 'a) = + "useOptimistic"; }; diff --git a/src/React.rei b/src/React.rei index f24d7273f..7c54cbcdc 100644 --- a/src/React.rei +++ b/src/React.rei @@ -568,6 +568,11 @@ external useTransition: unit => (bool, callback(callback(unit, unit), unit)) = module Experimental: { /* This module is used to bind to APIs for future versions of React. There is no guarantee of backwards compatibility or stability. */ [@mel.module "react"] external use: Js.Promise.t('a) => 'a = "use"; + + [@mel.module "react"] + external useOptimistic: + ('state, ('state, 'a) => 'state) => ('state, 'a => 'a) = + "useOptimistic"; }; [@mel.set] diff --git a/src/ReactDOM.re b/src/ReactDOM.re index ecc27cb7f..55c714626 100644 --- a/src/ReactDOM.re +++ b/src/ReactDOM.re @@ -1547,3 +1547,20 @@ external jsxs: (string, domProps) => React.element = "jsxs"; [@mel.module "react/jsx-runtime"] external jsxsKeyed: (string, domProps, ~key: string=?, unit) => React.element = "jsxs"; + +module Experimental = { + [@mel.module "react-dom"] + external useFormState: + ('state => 'state, 'state, ~permalink: string=?) => ('state, unit => unit) = + "useFormState"; + + type formStatus('formData) = { + pending: bool, + data: 'formData, + method: string, + action: Js.Nullable.t(unit => unit), + }; + + [@mel.module "react-dom"] + external useFormStatus: unit => formStatus('formData) = "useFormStatus"; +}; diff --git a/src/ReactDOM.rei b/src/ReactDOM.rei index 0d80a6a92..b04bd1b12 100644 --- a/src/ReactDOM.rei +++ b/src/ReactDOM.rei @@ -1548,3 +1548,20 @@ external jsxs: (string, domProps) => React.element = "jsxs"; [@mel.module "react/jsx-runtime"] external jsxsKeyed: (string, domProps, ~key: string=?, unit) => React.element = "jsxs"; + +module Experimental: { + [@mel.module "react-dom"] + external useFormState: + ('state => 'state, 'state, ~permalink: string=?) => ('state, unit => unit) = + "useFormState"; + + type formStatus('formData) = { + pending: bool, + data: 'formData, + method: string, + action: Js.Nullable.t(unit => unit), + }; + + [@mel.module "react-dom"] + external useFormStatus: unit => formStatus('formData) = "useFormStatus"; +};