mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
[DevTools] Stop setting unused global variables (#35532)
This commit is contained in:
1 parent
01c4d03d84
commit
bef88f7c11
3 files changed
+7
-32
No files matched your search
+6
-28
@@ -6,7 +6,10 @@ import {initBackend} from 'react-devtools-shared/src/backend';
|
||||
import {installHook} from 'react-devtools-shared/src/hook';
|
||||
import setupNativeStyleEditor from 'react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor';
|
||||
|
||||
import type {BackendBridge} from 'react-devtools-shared/src/bridge';
|
||||
import type {
|
||||
BackendBridge,
|
||||
SavedPreferencesParams,
|
||||
} from 'react-devtools-shared/src/bridge';
|
||||
import type {Wall} from 'react-devtools-shared/src/frontend/types';
|
||||
import {
|
||||
getIfReloadedAndProfiling,
|
||||
@@ -16,31 +19,14 @@ import {
|
||||
} from 'react-devtools-shared/src/utils';
|
||||
|
||||
function startActivation(contentWindow: any, bridge: BackendBridge) {
|
||||
const onSavedPreferences = (data: $FlowFixMe) => {
|
||||
const onSavedPreferences = (data: SavedPreferencesParams) => {
|
||||
// This is the only message we're listening for,
|
||||
// so it's safe to cleanup after we've received it.
|
||||
bridge.removeListener('savedPreferences', onSavedPreferences);
|
||||
|
||||
const {
|
||||
appendComponentStack,
|
||||
breakOnConsoleErrors,
|
||||
componentFilters,
|
||||
showInlineWarningsAndErrors,
|
||||
hideConsoleLogsInStrictMode,
|
||||
disableSecondConsoleLogDimmingInStrictMode,
|
||||
} = data;
|
||||
const {componentFilters} = data;
|
||||
|
||||
contentWindow.__REACT_DEVTOOLS_APPEND_COMPONENT_STACK__ =
|
||||
appendComponentStack;
|
||||
contentWindow.__REACT_DEVTOOLS_BREAK_ON_CONSOLE_ERRORS__ =
|
||||
breakOnConsoleErrors;
|
||||
contentWindow.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = componentFilters;
|
||||
contentWindow.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ =
|
||||
showInlineWarningsAndErrors;
|
||||
contentWindow.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__ =
|
||||
hideConsoleLogsInStrictMode;
|
||||
contentWindow.__REACT_DEVTOOLS_DISABLE_SECOND_CONSOLE_LOG_DIMMING_IN_STRICT_MODE__ =
|
||||
disableSecondConsoleLogDimmingInStrictMode;
|
||||
|
||||
// TRICKY
|
||||
// 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) {
|
||||
// Technically we don't need to store them on the contentWindow in this case,
|
||||
// but it doesn't really hurt anything to store them there too.
|
||||
if (contentWindow !== window) {
|
||||
window.__REACT_DEVTOOLS_APPEND_COMPONENT_STACK__ = appendComponentStack;
|
||||
window.__REACT_DEVTOOLS_BREAK_ON_CONSOLE_ERRORS__ = breakOnConsoleErrors;
|
||||
window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = componentFilters;
|
||||
window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ =
|
||||
showInlineWarningsAndErrors;
|
||||
window.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__ =
|
||||
hideConsoleLogsInStrictMode;
|
||||
window.__REACT_DEVTOOLS_DISABLE_SECOND_CONSOLE_LOG_DIMMING_IN_STRICT_MODE__ =
|
||||
disableSecondConsoleLogDimmingInStrictMode;
|
||||
}
|
||||
|
||||
finishActivation(contentWindow, bridge);
|
||||
|
||||
@@ -240,9 +240,6 @@ beforeEach(() => {
|
||||
setSavedComponentFilters(getDefaultComponentFilters());
|
||||
global.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = getDefaultComponentFilters();
|
||||
|
||||
// Also initialize inline warnings so that we can test them.
|
||||
global.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ = true;
|
||||
|
||||
installHook(global, {
|
||||
appendComponentStack: true,
|
||||
breakOnConsoleErrors: false,
|
||||
|
||||
+1
-1
@@ -191,7 +191,7 @@ type NativeStyleEditor_SetValueParams = {
|
||||
value: string,
|
||||
};
|
||||
|
||||
type SavedPreferencesParams = {
|
||||
export type SavedPreferencesParams = {
|
||||
componentFilters: Array<ComponentFilter>,
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user