Skip to content

Commit 40357fe

Browse files
authored
fix[react-devtools]: request hook initialization inside http server response (#31102)
Fixes #31100. There are 2 things: 1. In #30987, we've introduced a breaking change: importing `react-devtools-core` is no longer enough for installing React DevTools global Hook. You need to call `initialize`, in which you may provide initial settings. I am not adding settings here, because it is not implemented, and there are no plans for supporting this. 2. Calling `installHook` is not necessary inside `standalone.js`, because this script is running inside Electron wrapper (which is just a UI, not the app that we are debugging). We will loose the ability to use React DevTools on this React application, but I guess thats fine.
1 parent 654e387 commit 40357fe

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/react-devtools-core/src/standalone.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {registerDevToolsEventLogger} from 'react-devtools-shared/src/registerDev
1717
import {Server} from 'ws';
1818
import {join} from 'path';
1919
import {readFileSync} from 'fs';
20-
import {installHook} from 'react-devtools-shared/src/hook';
2120
import DevTools from 'react-devtools-shared/src/devtools/views/DevTools';
2221
import {doesFilePathExist, launchEditor} from './editor';
2322
import {
@@ -29,8 +28,6 @@ import {localStorageSetItem} from 'react-devtools-shared/src/storage';
2928
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
3029
import type {Source} from 'react-devtools-shared/src/shared/types';
3130

32-
installHook(window);
33-
3431
export type StatusTypes = 'server-connected' | 'devtools-connected' | 'error';
3532
export type StatusListener = (message: string, status: StatusTypes) => void;
3633
export type OnDisconnectedCallback = () => void;
@@ -371,9 +368,12 @@ function startServer(
371368
'\n;' +
372369
backendFile.toString() +
373370
'\n;' +
371+
'ReactDevToolsBackend.initialize();' +
372+
'\n' +
374373
`ReactDevToolsBackend.connectToDevTools({port: ${port}, host: '${host}', useHttps: ${
375374
useHttps ? 'true' : 'false'
376-
}});`,
375+
}});
376+
`,
377377
);
378378
});
379379

0 commit comments

Comments
 (0)