Skip to content

Commit

Permalink
fix[devtools/inspectElement]: dont pause initial inspectElement call …
Browse files Browse the repository at this point in the history
…when user switches tabs (#27488)

There are not so many changes, most of them are changing imports,
because I've moved types for UI in a single file.

In #27357 I've added support for
pausing polling events: when user inspects an element, we start polling
React DevTools backend for updates in props / state. If user switches
tabs, extension's service worker can be killed by browser and this
polling will start spamming errors.

What I've missed is that we also have a separate call for this API, but
which is executed only once when user selects an element. We don't
handle promise rejection here and this can lead to some errors when user
selects an element and switches tabs right after it.

The only change here is that this API now has
`shouldListenToPauseEvents` param, which is `true` for polling, so we
will pause polling once user switches tabs. It is `false` by default, so
we won't pause initial call by accident.

https://github.com/hoxyq/react/blob/af8beeebf63b5824497fcd0bb35b7c0ac8fe60a0/packages/react-devtools-shared/src/backendAPI.js#L96

DiffTrain build for commit 77ec618.
  • Loading branch information
hoxyq committed Oct 10, 2023
1 parent a19627e commit 1e8f15f
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24773,7 +24773,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-canary-151e75a12-20231010";
var ReactVersion = "18.3.0-canary-77ec61885-20231010";

// Might add PROFILE later.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8978,7 +8978,7 @@ var devToolsConfig$jscomp$inline_998 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-151e75a12-20231010",
version: "18.3.0-canary-77ec61885-20231010",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1191 = {
Expand Down Expand Up @@ -9009,7 +9009,7 @@ var internals$jscomp$inline_1191 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-151e75a12-20231010"
reconcilerVersion: "18.3.0-canary-77ec61885-20231010"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1192 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9404,7 +9404,7 @@ var devToolsConfig$jscomp$inline_1040 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-canary-151e75a12-20231010",
version: "18.3.0-canary-77ec61885-20231010",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1232 = {
Expand Down Expand Up @@ -9435,7 +9435,7 @@ var internals$jscomp$inline_1232 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-canary-151e75a12-20231010"
reconcilerVersion: "18.3.0-canary-77ec61885-20231010"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1233 = __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-151e75a12-20231010";
var ReactVersion = "18.3.0-canary-77ec61885-20231010";

// ATTENTION
// When adding new symbols to this file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,4 +616,4 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-151e75a12-20231010";
exports.version = "18.3.0-canary-77ec61885-20231010";
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ exports.useSyncExternalStore = function (
exports.useTransition = function () {
return ReactCurrentDispatcher.current.useTransition();
};
exports.version = "18.3.0-canary-151e75a12-20231010";
exports.version = "18.3.0-canary-77ec61885-20231010";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
151e75a128d0fd436dce365335b96c5686f704d4
77ec61885fb19607cdd116a6790095afa40b5a94

0 comments on commit 1e8f15f

Please sign in to comment.