[DevTools] Stop setting unused global variables (#35532)
Sebastian "Sebbie" Silbermann committed
Jan 16, 2026 at 16:13 UTC
bef88f7c115536b534f532f8b03c55e3697486c7
3 files changed
+8
-33
packages/react-devtools-inline/src/backend.js
+7
-29
@@ -6,7 +6,10 @@ import {initBackend} from 'react-devtools-shared/src/backend';
6
import {installHook} from 'react-devtools-shared/src/hook';
7
import setupNativeStyleEditor from 'react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor';
8
9
-import type {BackendBridge} from 'react-devtools-shared/src/bridge';
9
+import type {
10
+ BackendBridge,
11
+ SavedPreferencesParams,
12
+} from 'react-devtools-shared/src/bridge';
13
import type {Wall} from 'react-devtools-shared/src/frontend/types';
14
import {
15
getIfReloadedAndProfiling,
@@ -16,31 +19,14 @@ import {
19
} from 'react-devtools-shared/src/utils';
20
21
function startActivation(contentWindow: any, bridge: BackendBridge) {
19
- const onSavedPreferences = (data: $FlowFixMe) => {
22
+ const onSavedPreferences = (data: SavedPreferencesParams) => {
23
// This is the only message we're listening for,
24
// so it's safe to cleanup after we've received it.
25
bridge.removeListener('savedPreferences', onSavedPreferences);
26
24
- const {
25
- appendComponentStack,
26
- breakOnConsoleErrors,
27
- componentFilters,
28
- showInlineWarningsAndErrors,
29
- hideConsoleLogsInStrictMode,
30
- disableSecondConsoleLogDimmingInStrictMode,
31
- } = data;
32
-
33
- contentWindow.__REACT_DEVTOOLS_APPEND_COMPONENT_STACK__ =
34
- appendComponentStack;
35
- contentWindow.__REACT_DEVTOOLS_BREAK_ON_CONSOLE_ERRORS__ =
36
- breakOnConsoleErrors;
27
+ const {componentFilters} = data;
28
+
29
contentWindow.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = componentFilters;
38
- contentWindow.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ =
39
- showInlineWarningsAndErrors;
40
- contentWindow.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__ =
41
- hideConsoleLogsInStrictMode;
42
- contentWindow.__REACT_DEVTOOLS_DISABLE_SECOND_CONSOLE_LOG_DIMMING_IN_STRICT_MODE__ =
43
- disableSecondConsoleLogDimmingInStrictMode;
30
31
// TRICKY
32
// The backend entry point may be required in the context of an iframe or the parent window.
@@ -49,15 +35,7 @@ function startActivation(contentWindow: any, bridge: BackendBridge) {
35
// Technically we don't need to store them on the contentWindow in this case,
36
// but it doesn't really hurt anything to store them there too.
37
if (contentWindow !== window) {
52
- window.__REACT_DEVTOOLS_APPEND_COMPONENT_STACK__ = appendComponentStack;
53
- window.__REACT_DEVTOOLS_BREAK_ON_CONSOLE_ERRORS__ = breakOnConsoleErrors;
38
window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = componentFilters;
55
- window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ =
56
- showInlineWarningsAndErrors;
57
- window.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__ =
58
- hideConsoleLogsInStrictMode;
59
- window.__REACT_DEVTOOLS_DISABLE_SECOND_CONSOLE_LOG_DIMMING_IN_STRICT_MODE__ =
60
- disableSecondConsoleLogDimmingInStrictMode;
39
}
40
41
finishActivation(contentWindow, bridge);
packages/react-devtools-shared/src/__tests__/setupTests.js
-3
@@ -240,9 +240,6 @@ beforeEach(() => {
240
setSavedComponentFilters(getDefaultComponentFilters());
241
global.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = getDefaultComponentFilters();
242
243
- // Also initialize inline warnings so that we can test them.
244
- global.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ = true;
245
-
243
installHook(global, {
244
appendComponentStack: true,
245
breakOnConsoleErrors: false,
packages/react-devtools-shared/src/bridge.js
+1
-1
@@ -191,7 +191,7 @@ type NativeStyleEditor_SetValueParams = {
191
value: string,
192
};
193
194
-type SavedPreferencesParams = {
194
+export type SavedPreferencesParams = {
195
componentFilters: Array<ComponentFilter>,
196
};
197