mirror of
https://github.com/facebook/react.git
synced 2026-02-24 20:53:03 +00:00
## Summary Initially reported in https://github.com/facebook/react/issues/26797. Was not able to reproduce the exact same problem, but found this case: 1. Open corresponding codepen from the issue in debug mode 2. Open components tab of the extension 3. Refresh the page Received multiple errors: - Warning in the Console tab: Invalid renderer id "2". - Error in the Components tab: Uncaught Error: Cannot add node "3" because a node with that id is already in the Store. This problem has occurred after landing a fix in https://github.com/facebook/react/pull/26779. Looks like Chrome is keeping the injected scripts (the backend in this case) and we start backend twice.
35 lines
930 B
JavaScript
35 lines
930 B
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
*/
|
|
|
|
import type {DevToolsHook} from 'react-devtools-shared/src/backend/types';
|
|
|
|
import Agent from 'react-devtools-shared/src/backend/agent';
|
|
import Bridge from 'react-devtools-shared/src/bridge';
|
|
import {initBackend} from 'react-devtools-shared/src/backend';
|
|
import setupNativeStyleEditor from 'react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor';
|
|
|
|
import {COMPACT_VERSION_NAME} from './utils';
|
|
|
|
setup(window.__REACT_DEVTOOLS_GLOBAL_HOOK__);
|
|
|
|
function setup(hook: ?DevToolsHook) {
|
|
if (hook == null) {
|
|
return;
|
|
}
|
|
|
|
hook.backends.set(COMPACT_VERSION_NAME, {
|
|
Agent,
|
|
Bridge,
|
|
initBackend,
|
|
setupNativeStyleEditor,
|
|
});
|
|
|
|
hook.emit('devtools-backend-installed', COMPACT_VERSION_NAME);
|
|
}
|