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

feat: add more React canary hooks #829

Draft
wants to merge 1 commit into
base: main
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
5 changes: 5 additions & 0 deletions src/React.re
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
5 changes: 5 additions & 0 deletions src/React.rei
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
17 changes: 17 additions & 0 deletions src/ReactDOM.re
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
17 changes: 17 additions & 0 deletions src/ReactDOM.rei
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
Loading