WarnIfLegacyBackendDetected.js — react Source File
Architecture documentation for WarnIfLegacyBackendDetected.js, a javascript file in the react codebase. 4 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 87fd0981_62e7_8a4e_e24c_67f948fec1d9["WarnIfLegacyBackendDetected.js"] 913bb343_55ea_f1b8_08f5_b75cb0a92b76["context.js"] 87fd0981_62e7_8a4e_e24c_67f948fec1d9 --> 913bb343_55ea_f1b8_08f5_b75cb0a92b76 899cf357_78bc_8627_bd54_2c00e2c9fde2["ModalDialog.js"] 87fd0981_62e7_8a4e_e24c_67f948fec1d9 --> 899cf357_78bc_8627_bd54_2c00e2c9fde2 00b2857f_23f2_e708_1af3_4e823d05eccc["WarnIfLegacyBackendDetected.css"] 87fd0981_62e7_8a4e_e24c_67f948fec1d9 --> 00b2857f_23f2_e708_1af3_4e823d05eccc ac587885_e294_a1e9_b13f_5e7b920fdb42["react"] 87fd0981_62e7_8a4e_e24c_67f948fec1d9 --> ac587885_e294_a1e9_b13f_5e7b920fdb42 e2c52a93_982e_407f_9fee_e89aa134ae9d["DevTools.js"] e2c52a93_982e_407f_9fee_e89aa134ae9d --> 87fd0981_62e7_8a4e_e24c_67f948fec1d9 style 87fd0981_62e7_8a4e_e24c_67f948fec1d9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* 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 * as React from 'react';
import {Fragment, useContext, useEffect} from 'react';
import {BridgeContext} from './context';
import {ModalDialogContext} from './ModalDialog';
import styles from './WarnIfLegacyBackendDetected.css';
export default function WarnIfLegacyBackendDetected(_: {}): null {
const bridge = useContext(BridgeContext);
const {dispatch} = useContext(ModalDialogContext);
// Detect pairing with legacy v3 backend.
// We do this by listening to a message that it broadcasts but the v4 backend doesn't.
// In this case the frontend should show upgrade instructions.
useEffect(() => {
// Wall.listen returns a cleanup function
let unlisten: $FlowFixMe = bridge.wall.listen(message => {
switch (message.type) {
case 'call':
case 'event':
case 'many-events':
// Any of these types indicate the v3 backend.
dispatch({
canBeDismissed: false,
id: 'WarnIfLegacyBackendDetected',
type: 'SHOW',
title: 'DevTools v4 is incompatible with this version of React',
content: <InvalidBackendDetected />,
});
// Once we've identified the backend version, it's safe to unsubscribe.
if (typeof unlisten === 'function') {
unlisten();
unlisten = null;
}
break;
default:
break;
}
switch (message.event) {
case 'isBackendStorageAPISupported':
case 'isNativeStyleEditorSupported':
case 'operations':
case 'overrideComponentFilters':
// Any of these is sufficient to indicate a v4 backend.
// Once we've identified the backend version, it's safe to unsubscribe.
if (typeof unlisten === 'function') {
unlisten();
unlisten = null;
}
break;
default:
break;
}
});
return () => {
if (typeof unlisten === 'function') {
unlisten();
unlisten = null;
}
};
}, [bridge, dispatch]);
return null;
}
function InvalidBackendDetected(_: {}) {
return (
<Fragment>
<p>Either upgrade React or install React DevTools v3:</p>
<code className={styles.Command}>npm install -d react-devtools@^3</code>
</Fragment>
);
}
Domain
Subdomains
Dependencies
Source
Frequently Asked Questions
What does WarnIfLegacyBackendDetected.js do?
WarnIfLegacyBackendDetected.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in WarnIfLegacyBackendDetected.js?
WarnIfLegacyBackendDetected.js defines 2 function(s): InvalidBackendDetected, WarnIfLegacyBackendDetected.
What does WarnIfLegacyBackendDetected.js depend on?
WarnIfLegacyBackendDetected.js imports 4 module(s): ModalDialog.js, WarnIfLegacyBackendDetected.css, context.js, react.
What files import WarnIfLegacyBackendDetected.js?
WarnIfLegacyBackendDetected.js is imported by 1 file(s): DevTools.js.
Where is WarnIfLegacyBackendDetected.js in the architecture?
WarnIfLegacyBackendDetected.js is located at packages/react-devtools-shared/src/devtools/views/WarnIfLegacyBackendDetected.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/devtools/views).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free