Skip to content

Commit 2bd9065

Browse files
committed
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 [b4cdd3e](b4cdd3e)
1 parent ff6e098 commit 2bd9065

21 files changed

+134
-35
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
31034b6de73c7cd9093e92a34e384d84c082aa4e
1+
b4cdd3e8922713f8c9817b004a0dc51be47bc5df

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (
2727
}
2828
"use strict";
2929

30-
var ReactVersion = "18.3.0-www-modern-a61c0c27";
30+
var ReactVersion = "18.3.0-www-modern-fd93b451";
3131

3232
// ATTENTION
3333
// When adding new symbols to this file,

compiled/facebook-www/ReactART-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
6969
return self;
7070
}
7171

72-
var ReactVersion = "18.3.0-www-modern-293df28d";
72+
var ReactVersion = "18.3.0-www-modern-3c71bf82";
7373

7474
var LegacyRoot = 0;
7575
var ConcurrentRoot = 1;

compiled/facebook-www/ReactART-prod.modern.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9756,7 +9756,7 @@ var slice = Array.prototype.slice,
97569756
return null;
97579757
},
97589758
bundleType: 0,
9759-
version: "18.3.0-www-modern-ce3b7ded",
9759+
version: "18.3.0-www-modern-2994e97d",
97609760
rendererPackageName: "react-art"
97619761
};
97629762
var internals$jscomp$inline_1283 = {
@@ -9787,7 +9787,7 @@ var internals$jscomp$inline_1283 = {
97879787
scheduleRoot: null,
97889788
setRefreshHandler: null,
97899789
getCurrentFiber: null,
9790-
reconcilerVersion: "18.3.0-www-modern-ce3b7ded"
9790+
reconcilerVersion: "18.3.0-www-modern-2994e97d"
97919791
};
97929792
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
97939793
var hook$jscomp$inline_1284 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled/facebook-www/ReactDOM-dev.classic.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,11 @@ function useFormStatus() {
983983
throw new Error("Not implemented.");
984984
}
985985
}
986+
function useFormState(action, initialState, url) {
987+
{
988+
throw new Error("Not implemented.");
989+
}
990+
}
986991

987992
var valueStack = [];
988993
var fiberStack;
@@ -33955,7 +33960,7 @@ function createFiberRoot(
3395533960
return root;
3395633961
}
3395733962

33958-
var ReactVersion = "18.3.0-www-classic-ca6e9201";
33963+
var ReactVersion = "18.3.0-www-classic-763d3541";
3395933964

3396033965
function createPortal$1(
3396133966
children,
@@ -47051,6 +47056,7 @@ assign(Internals, {
4705147056
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
4705247057
exports.createPortal = createPortal;
4705347058
exports.createRoot = createRoot;
47059+
exports.experimental_useFormState = useFormState;
4705447060
exports.experimental_useFormStatus = useFormStatus;
4705547061
exports.findDOMNode = findDOMNode;
4705647062
exports.flushSync = flushSync;

compiled/facebook-www/ReactDOM-dev.modern.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ function useFormStatus() {
155155
throw new Error("Not implemented.");
156156
}
157157
}
158+
function useFormState(action, initialState, url) {
159+
{
160+
throw new Error("Not implemented.");
161+
}
162+
}
158163

159164
var valueStack = [];
160165
var fiberStack;
@@ -33800,7 +33805,7 @@ function createFiberRoot(
3380033805
return root;
3380133806
}
3380233807

33803-
var ReactVersion = "18.3.0-www-modern-293df28d";
33808+
var ReactVersion = "18.3.0-www-modern-3c71bf82";
3380433809

3380533810
function createPortal$1(
3380633811
children,
@@ -46120,6 +46125,7 @@ var foundDevTools = injectIntoDevTools({
4612046125
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
4612146126
exports.createPortal = createPortal;
4612246127
exports.createRoot = createRoot;
46128+
exports.experimental_useFormState = useFormState;
4612346129
exports.experimental_useFormStatus = useFormStatus;
4612446130
exports.flushSync = flushSync;
4612546131
exports.hydrateRoot = hydrateRoot;

compiled/facebook-www/ReactDOM-prod.classic.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16671,7 +16671,7 @@ Internals.Events = [
1667116671
var devToolsConfig$jscomp$inline_1783 = {
1667216672
findFiberByHostInstance: getClosestInstanceFromNode,
1667316673
bundleType: 0,
16674-
version: "18.3.0-www-classic-bbf92da7",
16674+
version: "18.3.0-www-classic-13155cf9",
1667516675
rendererPackageName: "react-dom"
1667616676
};
1667716677
var internals$jscomp$inline_2140 = {
@@ -16701,7 +16701,7 @@ var internals$jscomp$inline_2140 = {
1670116701
scheduleRoot: null,
1670216702
setRefreshHandler: null,
1670316703
getCurrentFiber: null,
16704-
reconcilerVersion: "18.3.0-www-classic-bbf92da7"
16704+
reconcilerVersion: "18.3.0-www-classic-13155cf9"
1670516705
};
1670616706
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1670716707
var hook$jscomp$inline_2141 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -16767,6 +16767,9 @@ exports.createRoot = function (container, options) {
1676716767
);
1676816768
return new ReactDOMRoot(options);
1676916769
};
16770+
exports.experimental_useFormState = function () {
16771+
throw Error(formatProdErrorMessage(248));
16772+
};
1677016773
exports.experimental_useFormStatus = function () {
1677116774
throw Error(formatProdErrorMessage(248));
1677216775
};
@@ -16937,4 +16940,4 @@ exports.unstable_renderSubtreeIntoContainer = function (
1693716940
);
1693816941
};
1693916942
exports.unstable_runWithPriority = runWithPriority;
16940-
exports.version = "18.3.0-www-classic-bbf92da7";
16943+
exports.version = "18.3.0-www-classic-13155cf9";

compiled/facebook-www/ReactDOM-prod.modern.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16201,7 +16201,7 @@ Internals.Events = [
1620116201
var devToolsConfig$jscomp$inline_1742 = {
1620216202
findFiberByHostInstance: getClosestInstanceFromNode,
1620316203
bundleType: 0,
16204-
version: "18.3.0-www-modern-ce3b7ded",
16204+
version: "18.3.0-www-modern-2994e97d",
1620516205
rendererPackageName: "react-dom"
1620616206
};
1620716207
var internals$jscomp$inline_2104 = {
@@ -16232,7 +16232,7 @@ var internals$jscomp$inline_2104 = {
1623216232
scheduleRoot: null,
1623316233
setRefreshHandler: null,
1623416234
getCurrentFiber: null,
16235-
reconcilerVersion: "18.3.0-www-modern-ce3b7ded"
16235+
reconcilerVersion: "18.3.0-www-modern-2994e97d"
1623616236
};
1623716237
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
1623816238
var hook$jscomp$inline_2105 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
@@ -16291,6 +16291,9 @@ exports.createRoot = function (container, options) {
1629116291
);
1629216292
return new ReactDOMRoot(options);
1629316293
};
16294+
exports.experimental_useFormState = function () {
16295+
throw Error(formatProdErrorMessage(248));
16296+
};
1629416297
exports.experimental_useFormStatus = function () {
1629516298
throw Error(formatProdErrorMessage(248));
1629616299
};
@@ -16396,4 +16399,4 @@ exports.unstable_createEventHandle = function (type, options) {
1639616399
return eventHandle;
1639716400
};
1639816401
exports.unstable_runWithPriority = runWithPriority;
16399-
exports.version = "18.3.0-www-modern-ce3b7ded";
16402+
exports.version = "18.3.0-www-modern-2994e97d";

compiled/facebook-www/ReactDOM-profiling.classic.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17446,7 +17446,7 @@ Internals.Events = [
1744617446
var devToolsConfig$jscomp$inline_1868 = {
1744717447
findFiberByHostInstance: getClosestInstanceFromNode,
1744817448
bundleType: 0,
17449-
version: "18.3.0-www-classic-e408ab62",
17449+
version: "18.3.0-www-classic-4c091427",
1745017450
rendererPackageName: "react-dom"
1745117451
};
1745217452
(function (internals) {
@@ -17490,7 +17490,7 @@ var devToolsConfig$jscomp$inline_1868 = {
1749017490
scheduleRoot: null,
1749117491
setRefreshHandler: null,
1749217492
getCurrentFiber: null,
17493-
reconcilerVersion: "18.3.0-www-classic-e408ab62"
17493+
reconcilerVersion: "18.3.0-www-classic-4c091427"
1749417494
});
1749517495
assign(Internals, {
1749617496
ReactBrowserEventEmitter: {
@@ -17543,6 +17543,9 @@ exports.createRoot = function (container, options) {
1754317543
);
1754417544
return new ReactDOMRoot(options);
1754517545
};
17546+
exports.experimental_useFormState = function () {
17547+
throw Error(formatProdErrorMessage(248));
17548+
};
1754617549
exports.experimental_useFormStatus = function () {
1754717550
throw Error(formatProdErrorMessage(248));
1754817551
};
@@ -17713,7 +17716,7 @@ exports.unstable_renderSubtreeIntoContainer = function (
1771317716
);
1771417717
};
1771517718
exports.unstable_runWithPriority = runWithPriority;
17716-
exports.version = "18.3.0-www-classic-e408ab62";
17719+
exports.version = "18.3.0-www-classic-4c091427";
1771717720

1771817721
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
1771917722
if (

compiled/facebook-www/ReactDOM-profiling.modern.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16970,7 +16970,7 @@ Internals.Events = [
1697016970
var devToolsConfig$jscomp$inline_1827 = {
1697116971
findFiberByHostInstance: getClosestInstanceFromNode,
1697216972
bundleType: 0,
16973-
version: "18.3.0-www-modern-4c5a5509",
16973+
version: "18.3.0-www-modern-42b59a98",
1697416974
rendererPackageName: "react-dom"
1697516975
};
1697616976
(function (internals) {
@@ -17015,7 +17015,7 @@ var devToolsConfig$jscomp$inline_1827 = {
1701517015
scheduleRoot: null,
1701617016
setRefreshHandler: null,
1701717017
getCurrentFiber: null,
17018-
reconcilerVersion: "18.3.0-www-modern-4c5a5509"
17018+
reconcilerVersion: "18.3.0-www-modern-42b59a98"
1701917019
});
1702017020
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
1702117021
exports.createPortal = function (children, container) {
@@ -17061,6 +17061,9 @@ exports.createRoot = function (container, options) {
1706117061
);
1706217062
return new ReactDOMRoot(options);
1706317063
};
17064+
exports.experimental_useFormState = function () {
17065+
throw Error(formatProdErrorMessage(248));
17066+
};
1706417067
exports.experimental_useFormStatus = function () {
1706517068
throw Error(formatProdErrorMessage(248));
1706617069
};
@@ -17166,7 +17169,7 @@ exports.unstable_createEventHandle = function (type, options) {
1716617169
return eventHandle;
1716717170
};
1716817171
exports.unstable_runWithPriority = runWithPriority;
17169-
exports.version = "18.3.0-www-modern-4c5a5509";
17172+
exports.version = "18.3.0-www-modern-42b59a98";
1717017173

1717117174
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
1717217175
if (

0 commit comments

Comments
 (0)