mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
fix[devtools/useTransition]: don't check for dispatch property when determining if hook is stateful (#27365)
https://github.com/facebook/react/pull/26740 introduced regression: React DevTools doesn't record updates for `useTransition` hook. I can add more details about things on DevTools side, if needed. The root cause is https://github.com/facebook/react/blob/491aec5d6113ce5bae7c10966bc38a4a8fc091a8/packages/react-reconciler/src/ReactFiberHooks.js#L2728-L2730 React DevTools expects dispatch to be present for stateful hooks that can schedule an update - https://github.com/facebook/react/blob/2eed1328478e8c923fcb4e6abf5efbd9e1233402/packages/react-devtools-shared/src/backend/renderer.js#L1422-L1428 With these changes, we still call dispatch in `startTransition`, but also patch `queue` object with it, so that React DevTools can recognise `useTransition` as stateful hook that can schedule update. I am not sure if this is the right approach to fix this, can we distinguish if `startTransition` was called from `useTransition` hook or as a standalone function? DiffTrain build for commit https://github.com/facebook/react/commit/56b14477e902ac076018be2e7bf2ea3092ac9e7d.
This commit is contained in:
+1
-1
@@ -23998,7 +23998,7 @@ function createFiberRoot(
|
||||
return root;
|
||||
}
|
||||
|
||||
var ReactVersion = "18.3.0-canary-68ac6dbcf-20230921";
|
||||
var ReactVersion = "18.3.0-canary-56b14477e-20230921";
|
||||
|
||||
// Might add PROFILE later.
|
||||
|
||||
|
||||
+2
-2
@@ -8620,7 +8620,7 @@ var devToolsConfig$jscomp$inline_1028 = {
|
||||
throw Error("TestRenderer does not support findFiberByHostInstance()");
|
||||
},
|
||||
bundleType: 0,
|
||||
version: "18.3.0-canary-68ac6dbcf-20230921",
|
||||
version: "18.3.0-canary-56b14477e-20230921",
|
||||
rendererPackageName: "react-test-renderer"
|
||||
};
|
||||
var internals$jscomp$inline_1227 = {
|
||||
@@ -8651,7 +8651,7 @@ var internals$jscomp$inline_1227 = {
|
||||
scheduleRoot: null,
|
||||
setRefreshHandler: null,
|
||||
getCurrentFiber: null,
|
||||
reconcilerVersion: "18.3.0-canary-68ac6dbcf-20230921"
|
||||
reconcilerVersion: "18.3.0-canary-56b14477e-20230921"
|
||||
};
|
||||
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
||||
var hook$jscomp$inline_1228 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
||||
|
||||
+2
-2
@@ -9046,7 +9046,7 @@ var devToolsConfig$jscomp$inline_1070 = {
|
||||
throw Error("TestRenderer does not support findFiberByHostInstance()");
|
||||
},
|
||||
bundleType: 0,
|
||||
version: "18.3.0-canary-68ac6dbcf-20230921",
|
||||
version: "18.3.0-canary-56b14477e-20230921",
|
||||
rendererPackageName: "react-test-renderer"
|
||||
};
|
||||
var internals$jscomp$inline_1268 = {
|
||||
@@ -9077,7 +9077,7 @@ var internals$jscomp$inline_1268 = {
|
||||
scheduleRoot: null,
|
||||
setRefreshHandler: null,
|
||||
getCurrentFiber: null,
|
||||
reconcilerVersion: "18.3.0-canary-68ac6dbcf-20230921"
|
||||
reconcilerVersion: "18.3.0-canary-56b14477e-20230921"
|
||||
};
|
||||
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
||||
var hook$jscomp$inline_1269 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ if (
|
||||
}
|
||||
"use strict";
|
||||
|
||||
var ReactVersion = "18.3.0-canary-68ac6dbcf-20230921";
|
||||
var ReactVersion = "18.3.0-canary-56b14477e-20230921";
|
||||
|
||||
// ATTENTION
|
||||
// When adding new symbols to this file,
|
||||
|
||||
+1
-1
@@ -616,4 +616,4 @@ exports.useSyncExternalStore = function (
|
||||
exports.useTransition = function () {
|
||||
return ReactCurrentDispatcher.current.useTransition();
|
||||
};
|
||||
exports.version = "18.3.0-canary-68ac6dbcf-20230921";
|
||||
exports.version = "18.3.0-canary-56b14477e-20230921";
|
||||
|
||||
+1
-1
@@ -619,7 +619,7 @@ exports.useSyncExternalStore = function (
|
||||
exports.useTransition = function () {
|
||||
return ReactCurrentDispatcher.current.useTransition();
|
||||
};
|
||||
exports.version = "18.3.0-canary-68ac6dbcf-20230921";
|
||||
exports.version = "18.3.0-canary-56b14477e-20230921";
|
||||
|
||||
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
||||
if (
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
68ac6dbcf8d58a67e94e9061395dd96a52d92377
|
||||
56b14477e902ac076018be2e7bf2ea3092ac9e7d
|
||||
|
||||
Reference in New Issue
Block a user