fix[react-devtools]: request hook initialization inside http server response (#31102)
Fixes https://github.com/facebook/react/issues/31100. There are 2 things: 1. In https://github.com/facebook/react/pull/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.
Ruslan Lesiutin committed
Oct 1, 2024 at 14:03 UTC
40357fe63071950b0bba304657a003755aec4e30
1 file changed
+4
-4
packages/react-devtools-core/src/standalone.js
+4
-4
@@ -17,7 +17,6 @@ import {registerDevToolsEventLogger} from 'react-devtools-shared/src/registerDev
17
import {Server} from 'ws';
18
import {join} from 'path';
19
import {readFileSync} from 'fs';
20
-import {installHook} from 'react-devtools-shared/src/hook';
20
import DevTools from 'react-devtools-shared/src/devtools/views/DevTools';
21
import {doesFilePathExist, launchEditor} from './editor';
22
import {
@@ -29,8 +28,6 @@ import {localStorageSetItem} from 'react-devtools-shared/src/storage';
28
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
29
import type {Source} from 'react-devtools-shared/src/shared/types';
30
32
-installHook(window);
33
-
31
export type StatusTypes = 'server-connected' | 'devtools-connected' | 'error';
32
export type StatusListener = (message: string, status: StatusTypes) => void;
33
export type OnDisconnectedCallback = () => void;
@@ -371,9 +368,12 @@ function startServer(
368
'\n;' +
369
backendFile.toString() +
370
'\n;' +
371
+ 'ReactDevToolsBackend.initialize();' +
372
+ '\n' +
373
`ReactDevToolsBackend.connectToDevTools({port: ${port}, host: '${host}', useHttps: ${
374
useHttps ? 'true' : 'false'
376
- }});`,
375
+ }});
376
+ `,
377
);
378
});
379