Skip to content

Commit 919a40a

Browse files
committed
React 19 API fixes
1 parent 8b5b33a commit 919a40a

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

src/React.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,4 +472,4 @@ useEffectEvent is a React Hook that lets you extract non-reactive logic from you
472472
[Read more on the React Documentation](https://react.dev/reference/react/useEffectEvent)
473473
*/
474474
@module("react")
475-
external useEffectEvent: ('event => unit) => 'event => unit = "useEffectEvent"
475+
external useEffectEvent: 'callback => 'callback = "useEffectEvent"

src/ReactDOM.res

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,24 @@ module Ref = {
9191

9292
// Hooks
9393

94-
type formStatus<'state> = {
94+
type formStatusAction = FormData.t => unit
95+
96+
type formStatus = {
9597
/** If true, this means the parent <form> is pending submission. Otherwise, false. */
9698
pending: bool,
9799
/** An object implementing the FormData interface that contains the data the parent <form> is submitting. If there is no active submission or no parent <form>, it will be null. */
98-
data: FormData.t,
100+
data: nullable<FormData.t>,
99101
/** This represents whether the parent <form> is submitting with either a GET or POST HTTP method. By default, a <form> will use the GET method and can be specified by the method property. */
100-
method: [#get | #post],
102+
method: nullable<[#get | #post]>,
101103
/** A reference to the function passed to the action prop on the parent <form>. If there is no parent <form>, 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. */
102-
action: React.action<'state, FormData.t>,
104+
action: nullable<formStatusAction>,
103105
}
104106

105107
external formAction: React.formAction<FormData.t> => string = "%identity"
106108

107109
/** `useFormStatus` is a Hook that gives you status information of the last form submission. */
108110
@module("react-dom")
109-
external useFormStatus: unit => formStatus<'state> = "useFormStatus"
111+
external useFormStatus: unit => formStatus = "useFormStatus"
110112

111113
// Resource Preloading APIs
112114

src/ReactDOMServer.res

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ type resumeOptions<'error> = {
1010
onError?: 'error => unit,
1111
}
1212

13+
type resumeToPipeableStreamOptions<'error> = {
14+
...resumeOptions<'error>,
15+
onAllReady?: unit => unit,
16+
onShellReady?: unit => unit,
17+
onShellError?: 'error => unit,
18+
}
19+
20+
type pipeableStream = {
21+
pipe: ReactDOMStatic.nodeStream => ReactDOMStatic.nodeStream,
22+
abort: unit => unit,
23+
}
24+
1325
/**
1426
resume streams a pre-rendered React tree to a Readable Web Stream.
1527
[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
2941
external resumeToPipeableStream: (
3042
React.element,
3143
ReactDOMStatic.postponedState,
32-
~options: resumeOptions<'error>=?,
33-
) => promise<ReactDOMStatic.nodeStream> = "resumeToPipeableStream"
44+
~options: resumeToPipeableStreamOptions<'error>=?,
45+
) => pipeableStream = "resumeToPipeableStream"

0 commit comments

Comments
 (0)