Skip to content

Commit

Permalink
Bugfix: useFormState queues actions in wrong order (#27570)
Browse files Browse the repository at this point in the history
I neglected to update the "last" pointer of the action queue. Since the
queue is circular, rather than dropping the update, the effect was to
add the update to the front of the queue instead of the back. I didn't
notice earlier because in my demos/tests, the actions would either
resolve really quickly or the actions weren't order dependent (like
incrementing a counter).

DiffTrain build for commit b8e47d9.
  • Loading branch information
acdlite committed Oct 23, 2023
1 parent 56c48f7 commit 52f3da8
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<4aba8405b48af51650328aaea1ae0e6d>>
* @generated SignedSource<<cbd8ea0713685000d0b28083e1b0ef92>>
*/

'use strict';
Expand Down Expand Up @@ -8054,7 +8054,7 @@ function dispatchFormState(fiber, actionQueue, setState, payload) {
payload: payload,
next: first
};
last.next = _newLast;
actionQueue.pending = last.next = _newLast;
}
}

Expand Down Expand Up @@ -24887,7 +24887,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-canary-05fbd1aab-20231023";
var ReactVersion = "18.3.0-canary-b8e47d988-20231023";

// Might add PROFILE later.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<af98f481db9b1e6f45f4f7d9c8ec7113>>
* @generated SignedSource<<3c60c6d80dc890b93e2083f2bdb9724f>>
*/

"use strict";
Expand Down Expand Up @@ -2694,7 +2694,8 @@ function dispatchFormState(fiber, actionQueue, setState, payload) {
? ((fiber = { payload: payload, next: null }),
(fiber.next = actionQueue.pending = fiber),
runFormStateAction(actionQueue, setState, payload))
: (fiber.next = { payload: payload, next: fiber.next });
: (actionQueue.pending = fiber.next =
{ payload: payload, next: fiber.next });
}
function runFormStateAction(actionQueue, setState, payload) {
var action = actionQueue.action,
Expand Down Expand Up @@ -9024,7 +9025,7 @@ var devToolsConfig$jscomp$inline_1032 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-05fbd1aab-20231023",
version: "18.3.0-canary-b8e47d988-20231023",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1225 = {
Expand Down Expand Up @@ -9055,7 +9056,7 @@ var internals$jscomp$inline_1225 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-05fbd1aab-20231023"
reconcilerVersion: "18.3.0-canary-b8e47d988-20231023"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1226 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @noflow
* @nolint
* @preventMunge
* @generated SignedSource<<55d6fdb51293e0bfc3d0f87e833cd9af>>
* @generated SignedSource<<a02b9b5dea9f5b94464f6051b23b425e>>
*/

"use strict";
Expand Down Expand Up @@ -2714,7 +2714,8 @@ function dispatchFormState(fiber, actionQueue, setState, payload) {
? ((fiber = { payload: payload, next: null }),
(fiber.next = actionQueue.pending = fiber),
runFormStateAction(actionQueue, setState, payload))
: (fiber.next = { payload: payload, next: fiber.next });
: (actionQueue.pending = fiber.next =
{ payload: payload, next: fiber.next });
}
function runFormStateAction(actionQueue, setState, payload) {
var action = actionQueue.action,
Expand Down Expand Up @@ -9450,7 +9451,7 @@ var devToolsConfig$jscomp$inline_1074 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-05fbd1aab-20231023",
version: "18.3.0-canary-b8e47d988-20231023",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1266 = {
Expand Down Expand Up @@ -9481,7 +9482,7 @@ var internals$jscomp$inline_1266 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-05fbd1aab-20231023"
reconcilerVersion: "18.3.0-canary-b8e47d988-20231023"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1267 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-canary-05fbd1aab-20231023";
var ReactVersion = "18.3.0-canary-b8e47d988-20231023";

// ATTENTION
// When adding new symbols to this file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,4 +580,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-05fbd1aab-20231023";
exports.version = "18.3.0-canary-b8e47d988-20231023";
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-05fbd1aab-20231023";
exports.version = "18.3.0-canary-b8e47d988-20231023";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
05fbd1aab036ecbd14469d6376024439bc931f68
b8e47d988eb3ba547c102c0b12c351250ed955e0

0 comments on commit 52f3da8

Please sign in to comment.