React 19 API fixes - #161
Conversation
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 919a40a2ba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Hooks | ||
|
|
||
| type formStatus<'state> = { | ||
| type formStatusAction = FormData.t => unit |
There was a problem hiding this comment.
Preserve async form action return values
When the parent form uses an async action, including the React.formAction<FormData.t> supported on line 107, useFormStatus().action refers to a function returning promise<unit> at runtime. Typing every status action as FormData.t => unit prevents callers from awaiting or handling that promise and can turn a rejected action into an unhandled rejection; this type should represent both synchronous and asynchronous form actions rather than discarding the return value.
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
I prefer keeping the function type with 1 argument, that will cover almost all the use cases of |
|
We do have the exact same issue with @module("react")
external useCallback: ('f, 'deps) => 'f = "useCallback"I think we should do the same here for consistency. |
Summary
Correct several React 19 and React 19.2 bindings so their ReScript types match the runtime APIs.
Changes
useEffectEventPreserve the callback’s complete type:
The previous binding only supported callbacks returning
unitwith at most one argument. React allows Effect Events to accept any number of arguments, return any value, and retain the original callback signature.useFormStatusAlign the returned status with React’s pending and non-pending states:
datanullable when no form submission is active.methodnullable because it isnullin the non-pending state.actionnullable when no function action is associated with the form.actionas a one-argumentFormDatacallback instead of auseActionStatereducer.'statetype parameter that resulted from the incorrect reducer type.resumeToPipeableStreamCorrect the Node.js streaming API:
{pipe, abort}controller directly instead of aPromise.pipeableStreamtype.onAllReadyonShellReadyonShellErrornonce,signal, andonErroroptions.React returns this controller synchronously; the previous binding incorrectly described it as a promise resolving to a Node stream.