Scaffolding for useFormState (#27270)

This exposes, but does not yet implement, a new experimental API called
useFormState. It's gated behind the enableAsyncActions flag.

useFormState has a similar signature to useReducer, except instead of a
reducer it accepts an (async) action function. React will wait until the
promise resolves before updating the state:

```js
async function action(prevState, payload) {
  // ..
}
const [state, dispatch] = useFormState(action, initialState)
```

When used in combination with Server Actions, it will also support
progressive enhancement — a form that is submitted before it has
hydrated will have its state transferred to the next page. However, like
the other action-related hooks, it works with fully client-driven
actions, too.

DiffTrain build for commit https://github.com/facebook/react/commit/b4cdd3e8922713f8c9817b004a0dc51be47bc5df.
This commit is contained in:
acdlite
2023-08-23 15:04:56 +00:00
parent d9702d1b26
commit 5a71bfb497
7 changed files with 9 additions and 9 deletions
@@ -23977,7 +23977,7 @@ function createFiberRoot(
return root;
}
var ReactVersion = "18.3.0-canary-856dc5e43-20230822";
var ReactVersion = "18.3.0-canary-b4cdd3e89-20230823";
// Might add PROFILE later.
@@ -8612,7 +8612,7 @@ var devToolsConfig$jscomp$inline_1029 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-856dc5e43-20230822",
version: "18.3.0-canary-b4cdd3e89-20230823",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1228 = {
@@ -8643,7 +8643,7 @@ var internals$jscomp$inline_1228 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-856dc5e43-20230822"
reconcilerVersion: "18.3.0-canary-b4cdd3e89-20230823"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1229 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -9038,7 +9038,7 @@ var devToolsConfig$jscomp$inline_1071 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-856dc5e43-20230822",
version: "18.3.0-canary-b4cdd3e89-20230823",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1269 = {
@@ -9069,7 +9069,7 @@ var internals$jscomp$inline_1269 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-856dc5e43-20230822"
reconcilerVersion: "18.3.0-canary-b4cdd3e89-20230823"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1270 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -27,7 +27,7 @@ if (
}
"use strict";
var ReactVersion = "18.3.0-canary-856dc5e43-20230822";
var ReactVersion = "18.3.0-canary-b4cdd3e89-20230823";
// ATTENTION
// When adding new symbols to this file,
@@ -616,4 +616,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-856dc5e43-20230822";
exports.version = "18.3.0-canary-b4cdd3e89-20230823";
@@ -619,7 +619,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-856dc5e43-20230822";
exports.version = "18.3.0-canary-b4cdd3e89-20230823";
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
@@ -1 +1 @@
856dc5e43352454b1d06c13e233d565ceda77e61
b4cdd3e8922713f8c9817b004a0dc51be47bc5df