diff --git a/src/React.res b/src/React.res index 33aa4c7..7f4f533 100644 --- a/src/React.res +++ b/src/React.res @@ -472,4 +472,4 @@ useEffectEvent is a React Hook that lets you extract non-reactive logic from you [Read more on the React Documentation](https://react.dev/reference/react/useEffectEvent) */ @module("react") -external useEffectEvent: ('event => unit) => 'event => unit = "useEffectEvent" +external useEffectEvent: 'callback => 'callback = "useEffectEvent" diff --git a/src/ReactDOM.res b/src/ReactDOM.res index 5d5bdb5..64670af 100644 --- a/src/ReactDOM.res +++ b/src/ReactDOM.res @@ -91,22 +91,29 @@ module Ref = { // Hooks -type formStatus<'state> = { +@unboxed +type formStatusActionResult = + | @as(undefined) Sync + | Async(promise) + +type formStatusAction = FormData.t => formStatusActionResult + +type formStatus = { /** If true, this means the parent
is pending submission. Otherwise, false. */ pending: bool, /** An object implementing the FormData interface that contains the data the parent is submitting. If there is no active submission or no parent , it will be null. */ - data: FormData.t, + data: nullable, /** This represents whether the parent is submitting with either a GET or POST HTTP method. By default, a will use the GET method and can be specified by the method property. */ - method: [#get | #post], + method: nullable<[#get | #post]>, /** A reference to the function passed to the action prop on the parent . If there is no parent , the property is null. If there is a URI value provided to the action prop, or no action prop specified, status.action will be null. */ - action: React.action<'state, FormData.t>, + action: nullable, } external formAction: React.formAction => string = "%identity" /** `useFormStatus` is a Hook that gives you status information of the last form submission. */ @module("react-dom") -external useFormStatus: unit => formStatus<'state> = "useFormStatus" +external useFormStatus: unit => formStatus = "useFormStatus" // Resource Preloading APIs diff --git a/src/ReactDOMServer.res b/src/ReactDOMServer.res index 44b77fd..4b6079f 100644 --- a/src/ReactDOMServer.res +++ b/src/ReactDOMServer.res @@ -10,6 +10,18 @@ type resumeOptions<'error> = { onError?: 'error => unit, } +type resumeToPipeableStreamOptions<'error> = { + ...resumeOptions<'error>, + onAllReady?: unit => unit, + onShellReady?: unit => unit, + onShellError?: 'error => unit, +} + +type pipeableStream = { + pipe: ReactDOMStatic.nodeStream => ReactDOMStatic.nodeStream, + abort: unit => unit, +} + /** resume streams a pre-rendered React tree to a Readable Web Stream. [Read more on the React Documentation](https://react.dev/reference/react-dom/server/resume) @@ -29,5 +41,5 @@ resumeToPipeableStream streams a pre-rendered React tree to a pipeable Node.js external resumeToPipeableStream: ( React.element, ReactDOMStatic.postponedState, - ~options: resumeOptions<'error>=?, -) => promise = "resumeToPipeableStream" + ~options: resumeToPipeableStreamOptions<'error>=?, +) => pipeableStream = "resumeToPipeableStream"